nokolexbor 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/nokolexbor/config.h +186 -0
- data/ext/nokolexbor/extconf.rb +131 -0
- data/ext/nokolexbor/libxml/HTMLparser.h +320 -0
- data/ext/nokolexbor/libxml/SAX2.h +173 -0
- data/ext/nokolexbor/libxml/chvalid.h +230 -0
- data/ext/nokolexbor/libxml/debugXML.h +217 -0
- data/ext/nokolexbor/libxml/dict.h +81 -0
- data/ext/nokolexbor/libxml/encoding.h +232 -0
- data/ext/nokolexbor/libxml/entities.h +153 -0
- data/ext/nokolexbor/libxml/globals.h +529 -0
- data/ext/nokolexbor/libxml/hash.h +236 -0
- data/ext/nokolexbor/libxml/list.h +137 -0
- data/ext/nokolexbor/libxml/parser.h +1264 -0
- data/ext/nokolexbor/libxml/parserInternals.h +641 -0
- data/ext/nokolexbor/libxml/pattern.h +100 -0
- data/ext/nokolexbor/libxml/threads.h +94 -0
- data/ext/nokolexbor/libxml/tree.h +1315 -0
- data/ext/nokolexbor/libxml/uri.h +94 -0
- data/ext/nokolexbor/libxml/valid.h +448 -0
- data/ext/nokolexbor/libxml/xmlIO.h +369 -0
- data/ext/nokolexbor/libxml/xmlautomata.h +146 -0
- data/ext/nokolexbor/libxml/xmlerror.h +919 -0
- data/ext/nokolexbor/libxml/xmlexports.h +79 -0
- data/ext/nokolexbor/libxml/xmlmemory.h +226 -0
- data/ext/nokolexbor/libxml/xmlregexp.h +222 -0
- data/ext/nokolexbor/libxml/xmlstring.h +140 -0
- data/ext/nokolexbor/libxml/xmlversion.h +526 -0
- data/ext/nokolexbor/libxml/xpath.h +575 -0
- data/ext/nokolexbor/libxml/xpathInternals.h +632 -0
- data/ext/nokolexbor/libxml/xpointer.h +137 -0
- data/ext/nokolexbor/libxml.h +76 -0
- data/ext/nokolexbor/memory.c +39 -0
- data/ext/nokolexbor/nl_document.c +51 -0
- data/ext/nokolexbor/nl_node.c +790 -0
- data/ext/nokolexbor/nl_node_set.c +368 -0
- data/ext/nokolexbor/nl_xpath_context.c +200 -0
- data/ext/nokolexbor/nokolexbor.c +63 -0
- data/ext/nokolexbor/nokolexbor.h +37 -0
- data/ext/nokolexbor/private/buf.h +70 -0
- data/ext/nokolexbor/private/dict.h +11 -0
- data/ext/nokolexbor/private/enc.h +17 -0
- data/ext/nokolexbor/private/error.h +21 -0
- data/ext/nokolexbor/private/globals.h +9 -0
- data/ext/nokolexbor/private/memory.h +9 -0
- data/ext/nokolexbor/private/parser.h +27 -0
- data/ext/nokolexbor/private/string.h +9 -0
- data/ext/nokolexbor/private/threads.h +50 -0
- data/ext/nokolexbor/private/tree.h +18 -0
- data/ext/nokolexbor/private/xpath.h +7 -0
- data/ext/nokolexbor/timsort.h +601 -0
- data/ext/nokolexbor/xml_SAX2.c +80 -0
- data/ext/nokolexbor/xml_buf.c +363 -0
- data/ext/nokolexbor/xml_chvalid.c +334 -0
- data/ext/nokolexbor/xml_dict.c +1264 -0
- data/ext/nokolexbor/xml_encoding.c +124 -0
- data/ext/nokolexbor/xml_error.c +134 -0
- data/ext/nokolexbor/xml_globals.c +1085 -0
- data/ext/nokolexbor/xml_hash.c +1141 -0
- data/ext/nokolexbor/xml_memory.c +203 -0
- data/ext/nokolexbor/xml_parser.c +127 -0
- data/ext/nokolexbor/xml_parserInternals.c +338 -0
- data/ext/nokolexbor/xml_pattern.c +2375 -0
- data/ext/nokolexbor/xml_string.c +1051 -0
- data/ext/nokolexbor/xml_threads.c +881 -0
- data/ext/nokolexbor/xml_tree.c +148 -0
- data/ext/nokolexbor/xml_xpath.c +14743 -0
- data/lib/nokolexbor/attribute.rb +18 -0
- data/lib/nokolexbor/document.rb +6 -0
- data/lib/nokolexbor/node.rb +264 -0
- data/lib/nokolexbor/node_set.rb +124 -0
- data/lib/nokolexbor/version.rb +5 -0
- data/lib/nokolexbor/xpath_context.rb +14 -0
- data/lib/nokolexbor.rb +17 -0
- data/patches/0001-lexbor-support-text-pseudo-element.patch +137 -0
- data/patches/0002-lexbor-match-id-class-case-sensitive.patch +22 -0
- data/patches/0003-lexbor-attach-template-content-to-self.patch +13 -0
- data/vendor/lexbor/CMakeLists.txt +331 -0
- data/vendor/lexbor/config.cmake +890 -0
- data/vendor/lexbor/feature.cmake +134 -0
- data/vendor/lexbor/source/lexbor/core/array.c +208 -0
- data/vendor/lexbor/source/lexbor/core/array.h +100 -0
- data/vendor/lexbor/source/lexbor/core/array_obj.c +216 -0
- data/vendor/lexbor/source/lexbor/core/array_obj.h +134 -0
- data/vendor/lexbor/source/lexbor/core/avl.c +442 -0
- data/vendor/lexbor/source/lexbor/core/avl.h +82 -0
- data/vendor/lexbor/source/lexbor/core/base.h +86 -0
- data/vendor/lexbor/source/lexbor/core/bst.c +468 -0
- data/vendor/lexbor/source/lexbor/core/bst.h +108 -0
- data/vendor/lexbor/source/lexbor/core/bst_map.c +238 -0
- data/vendor/lexbor/source/lexbor/core/bst_map.h +87 -0
- data/vendor/lexbor/source/lexbor/core/config.cmake +12 -0
- data/vendor/lexbor/source/lexbor/core/conv.c +203 -0
- data/vendor/lexbor/source/lexbor/core/conv.h +53 -0
- data/vendor/lexbor/source/lexbor/core/core.h +35 -0
- data/vendor/lexbor/source/lexbor/core/def.h +57 -0
- data/vendor/lexbor/source/lexbor/core/diyfp.c +153 -0
- data/vendor/lexbor/source/lexbor/core/diyfp.h +258 -0
- data/vendor/lexbor/source/lexbor/core/dobject.c +187 -0
- data/vendor/lexbor/source/lexbor/core/dobject.h +92 -0
- data/vendor/lexbor/source/lexbor/core/dtoa.c +404 -0
- data/vendor/lexbor/source/lexbor/core/dtoa.h +28 -0
- data/vendor/lexbor/source/lexbor/core/fs.h +60 -0
- data/vendor/lexbor/source/lexbor/core/hash.c +476 -0
- data/vendor/lexbor/source/lexbor/core/hash.h +218 -0
- data/vendor/lexbor/source/lexbor/core/in.c +267 -0
- data/vendor/lexbor/source/lexbor/core/in.h +172 -0
- data/vendor/lexbor/source/lexbor/core/lexbor.h +35 -0
- data/vendor/lexbor/source/lexbor/core/mem.c +228 -0
- data/vendor/lexbor/source/lexbor/core/mem.h +141 -0
- data/vendor/lexbor/source/lexbor/core/mraw.c +428 -0
- data/vendor/lexbor/source/lexbor/core/mraw.h +114 -0
- data/vendor/lexbor/source/lexbor/core/perf.h +45 -0
- data/vendor/lexbor/source/lexbor/core/plog.c +73 -0
- data/vendor/lexbor/source/lexbor/core/plog.h +102 -0
- data/vendor/lexbor/source/lexbor/core/print.c +168 -0
- data/vendor/lexbor/source/lexbor/core/print.h +39 -0
- data/vendor/lexbor/source/lexbor/core/sbst.h +59 -0
- data/vendor/lexbor/source/lexbor/core/serialize.c +27 -0
- data/vendor/lexbor/source/lexbor/core/serialize.h +32 -0
- data/vendor/lexbor/source/lexbor/core/shs.c +118 -0
- data/vendor/lexbor/source/lexbor/core/shs.h +82 -0
- data/vendor/lexbor/source/lexbor/core/str.c +617 -0
- data/vendor/lexbor/source/lexbor/core/str.h +247 -0
- data/vendor/lexbor/source/lexbor/core/str_res.h +369 -0
- data/vendor/lexbor/source/lexbor/core/strtod.c +326 -0
- data/vendor/lexbor/source/lexbor/core/strtod.h +28 -0
- data/vendor/lexbor/source/lexbor/core/types.h +39 -0
- data/vendor/lexbor/source/lexbor/core/utils.c +43 -0
- data/vendor/lexbor/source/lexbor/core/utils.h +36 -0
- data/vendor/lexbor/source/lexbor/css/base.h +44 -0
- data/vendor/lexbor/source/lexbor/css/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/css/css.h +25 -0
- data/vendor/lexbor/source/lexbor/css/log.c +336 -0
- data/vendor/lexbor/source/lexbor/css/log.h +103 -0
- data/vendor/lexbor/source/lexbor/css/node.h +29 -0
- data/vendor/lexbor/source/lexbor/css/parser.c +473 -0
- data/vendor/lexbor/source/lexbor/css/parser.h +368 -0
- data/vendor/lexbor/source/lexbor/css/selectors/base.h +48 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo.c +91 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo.h +66 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_const.h +109 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_res.h +302 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_state.c +279 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_state.h +85 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selector.c +927 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selector.h +200 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selectors.c +340 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selectors.h +137 -0
- data/vendor/lexbor/source/lexbor/css/selectors/state.c +1718 -0
- data/vendor/lexbor/source/lexbor/css/selectors/state.h +79 -0
- data/vendor/lexbor/source/lexbor/css/stylesheet.h +37 -0
- data/vendor/lexbor/source/lexbor/css/syntax/anb.c +443 -0
- data/vendor/lexbor/source/lexbor/css/syntax/anb.h +45 -0
- data/vendor/lexbor/source/lexbor/css/syntax/base.h +33 -0
- data/vendor/lexbor/source/lexbor/css/syntax/parser.c +9 -0
- data/vendor/lexbor/source/lexbor/css/syntax/parser.h +25 -0
- data/vendor/lexbor/source/lexbor/css/syntax/res.h +48 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state.c +2603 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state.h +140 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state_res.h +273 -0
- data/vendor/lexbor/source/lexbor/css/syntax/syntax.c +67 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token.c +618 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token.h +298 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token_res.h +68 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer/error.c +30 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer/error.h +58 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer.c +278 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer.h +121 -0
- data/vendor/lexbor/source/lexbor/dom/base.h +32 -0
- data/vendor/lexbor/source/lexbor/dom/collection.c +97 -0
- data/vendor/lexbor/source/lexbor/dom/collection.h +112 -0
- data/vendor/lexbor/source/lexbor/dom/config.cmake +3 -0
- data/vendor/lexbor/source/lexbor/dom/dom.h +29 -0
- data/vendor/lexbor/source/lexbor/dom/exception.c +18 -0
- data/vendor/lexbor/source/lexbor/dom/exception.h +73 -0
- data/vendor/lexbor/source/lexbor/dom/interface.c +110 -0
- data/vendor/lexbor/source/lexbor/dom/interface.h +88 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr.c +445 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr.h +152 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr_const.h +62 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr_res.h +143 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/cdata_section.c +55 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/cdata_section.h +38 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/character_data.c +110 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/character_data.h +51 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/comment.c +64 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/comment.h +42 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document.c +536 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document.h +243 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_fragment.c +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_fragment.h +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_type.c +125 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_type.h +108 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/element.c +1411 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/element.h +319 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/event_target.c +32 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/event_target.h +34 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/node.c +661 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/node.h +192 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/processing_instruction.c +87 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/processing_instruction.h +66 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/shadow_root.c +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/shadow_root.h +44 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/text.c +63 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/text.h +42 -0
- data/vendor/lexbor/source/lexbor/encoding/base.h +218 -0
- data/vendor/lexbor/source/lexbor/encoding/big5.c +42839 -0
- data/vendor/lexbor/source/lexbor/encoding/config.cmake +12 -0
- data/vendor/lexbor/source/lexbor/encoding/const.h +65 -0
- data/vendor/lexbor/source/lexbor/encoding/decode.c +3193 -0
- data/vendor/lexbor/source/lexbor/encoding/decode.h +370 -0
- data/vendor/lexbor/source/lexbor/encoding/encode.c +1931 -0
- data/vendor/lexbor/source/lexbor/encoding/encode.h +377 -0
- data/vendor/lexbor/source/lexbor/encoding/encoding.c +252 -0
- data/vendor/lexbor/source/lexbor/encoding/encoding.h +475 -0
- data/vendor/lexbor/source/lexbor/encoding/euc_kr.c +53883 -0
- data/vendor/lexbor/source/lexbor/encoding/gb18030.c +47905 -0
- data/vendor/lexbor/source/lexbor/encoding/iso_2022_jp_katakana.c +159 -0
- data/vendor/lexbor/source/lexbor/encoding/jis0208.c +22477 -0
- data/vendor/lexbor/source/lexbor/encoding/jis0212.c +15787 -0
- data/vendor/lexbor/source/lexbor/encoding/multi.h +53 -0
- data/vendor/lexbor/source/lexbor/encoding/range.c +71 -0
- data/vendor/lexbor/source/lexbor/encoding/range.h +34 -0
- data/vendor/lexbor/source/lexbor/encoding/res.c +222 -0
- data/vendor/lexbor/source/lexbor/encoding/res.h +34 -0
- data/vendor/lexbor/source/lexbor/encoding/single.c +13748 -0
- data/vendor/lexbor/source/lexbor/encoding/single.h +116 -0
- data/vendor/lexbor/source/lexbor/html/base.h +44 -0
- data/vendor/lexbor/source/lexbor/html/config.cmake +3 -0
- data/vendor/lexbor/source/lexbor/html/encoding.c +574 -0
- data/vendor/lexbor/source/lexbor/html/encoding.h +106 -0
- data/vendor/lexbor/source/lexbor/html/html.h +107 -0
- data/vendor/lexbor/source/lexbor/html/interface.c +165 -0
- data/vendor/lexbor/source/lexbor/html/interface.h +186 -0
- data/vendor/lexbor/source/lexbor/html/interface_res.h +4449 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/anchor_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/anchor_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/area_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/area_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/audio_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/audio_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/base_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/base_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/body_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/body_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/br_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/br_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/button_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/button_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/canvas_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/canvas_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/d_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/d_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/details_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/details_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/dialog_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/dialog_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/directory_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/directory_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/div_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/div_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/document.c +444 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/document.h +256 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/element.c +64 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/element.h +54 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/embed_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/embed_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/field_set_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/field_set_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/font_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/font_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/form_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/form_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_set_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_set_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/head_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/head_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/heading_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/heading_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/hr_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/hr_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/html_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/html_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/iframe_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/iframe_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/image_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/image_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/input_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/input_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/label_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/label_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/legend_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/legend_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/li_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/li_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/link_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/link_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/map_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/map_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/marquee_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/marquee_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/media_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/media_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/menu_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/menu_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meta_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meta_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meter_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meter_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/mod_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/mod_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/o_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/o_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/object_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/object_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/opt_group_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/opt_group_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/option_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/option_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/output_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/output_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/paragraph_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/paragraph_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/param_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/param_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/picture_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/picture_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/pre_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/pre_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/progress_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/progress_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/quote_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/quote_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/script_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/script_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/select_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/select_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/slot_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/slot_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/source_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/source_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/span_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/span_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/style_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/style_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_caption_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_caption_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_cell_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_cell_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_col_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_col_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_row_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_row_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_section_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_section_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/template_element.c +46 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/template_element.h +38 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/text_area_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/text_area_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/time_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/time_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/title_element.c +133 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/title_element.h +42 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/track_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/track_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/u_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/u_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/unknown_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/unknown_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/video_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/video_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/window.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/window.h +34 -0
- data/vendor/lexbor/source/lexbor/html/node.c +14 -0
- data/vendor/lexbor/source/lexbor/html/node.h +67 -0
- data/vendor/lexbor/source/lexbor/html/parser.c +469 -0
- data/vendor/lexbor/source/lexbor/html/parser.h +170 -0
- data/vendor/lexbor/source/lexbor/html/serialize.c +1510 -0
- data/vendor/lexbor/source/lexbor/html/serialize.h +93 -0
- data/vendor/lexbor/source/lexbor/html/tag.h +103 -0
- data/vendor/lexbor/source/lexbor/html/tag_res.h +2262 -0
- data/vendor/lexbor/source/lexbor/html/token.c +386 -0
- data/vendor/lexbor/source/lexbor/html/token.h +130 -0
- data/vendor/lexbor/source/lexbor/html/token_attr.c +44 -0
- data/vendor/lexbor/source/lexbor/html/token_attr.h +67 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/error.c +28 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/error.h +141 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/res.h +4956 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state.c +2171 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state.h +225 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_comment.c +489 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_comment.h +27 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_doctype.c +1654 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_doctype.h +27 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rawtext.c +303 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rawtext.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rcdata.c +311 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rcdata.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_script.c +1209 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_script.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer.c +499 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer.h +343 -0
- data/vendor/lexbor/source/lexbor/html/tree/active_formatting.c +241 -0
- data/vendor/lexbor/source/lexbor/html/tree/active_formatting.h +117 -0
- data/vendor/lexbor/source/lexbor/html/tree/error.c +26 -0
- data/vendor/lexbor/source/lexbor/html/tree/error.h +114 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_after_body.c +62 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_after_frameset.c +63 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_body.c +82 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_frameset.c +88 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_head.c +222 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/before_head.c +144 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/before_html.c +166 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/foreign_content.c +358 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_body.c +1974 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_caption.c +158 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_cell.c +187 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_column_group.c +194 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_frameset.c +149 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_head.c +374 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_head_noscript.c +121 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_row.c +211 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_select.c +341 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_select_in_table.c +115 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table.c +451 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table_body.c +208 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table_text.c +127 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_template.c +189 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/initial.c +411 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/text.c +61 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode.h +135 -0
- data/vendor/lexbor/source/lexbor/html/tree/open_elements.c +251 -0
- data/vendor/lexbor/source/lexbor/html/tree/open_elements.h +105 -0
- data/vendor/lexbor/source/lexbor/html/tree/template_insertion.c +10 -0
- data/vendor/lexbor/source/lexbor/html/tree/template_insertion.h +100 -0
- data/vendor/lexbor/source/lexbor/html/tree.c +1726 -0
- data/vendor/lexbor/source/lexbor/html/tree.h +431 -0
- data/vendor/lexbor/source/lexbor/html/tree_res.h +111 -0
- data/vendor/lexbor/source/lexbor/ns/base.h +32 -0
- data/vendor/lexbor/source/lexbor/ns/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/ns/const.h +37 -0
- data/vendor/lexbor/source/lexbor/ns/ns.c +154 -0
- data/vendor/lexbor/source/lexbor/ns/ns.h +66 -0
- data/vendor/lexbor/source/lexbor/ns/res.h +97 -0
- data/vendor/lexbor/source/lexbor/ports/posix/config.cmake +11 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/fs.c +236 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/memory.c +33 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/perf.c +158 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/config.cmake +18 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/fs.c +239 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/memory.c +33 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/perf.c +81 -0
- data/vendor/lexbor/source/lexbor/selectors/base.h +30 -0
- data/vendor/lexbor/source/lexbor/selectors/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/selectors/selectors.c +1591 -0
- data/vendor/lexbor/source/lexbor/selectors/selectors.h +71 -0
- data/vendor/lexbor/source/lexbor/tag/base.h +32 -0
- data/vendor/lexbor/source/lexbor/tag/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/tag/const.h +225 -0
- data/vendor/lexbor/source/lexbor/tag/res.h +562 -0
- data/vendor/lexbor/source/lexbor/tag/tag.c +144 -0
- data/vendor/lexbor/source/lexbor/tag/tag.h +123 -0
- data/vendor/lexbor/source/lexbor/utils/base.h +32 -0
- data/vendor/lexbor/source/lexbor/utils/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/utils/http.c +534 -0
- data/vendor/lexbor/source/lexbor/utils/http.h +90 -0
- data/vendor/lexbor/source/lexbor/utils/utils.h +15 -0
- data/vendor/lexbor/source/lexbor/utils/warc.c +817 -0
- data/vendor/lexbor/source/lexbor/utils/warc.h +126 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/pseudo.py +231 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/tmp/const.h +21 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/tmp/res.h +26 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/definitions.py +49 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/token_res.py +54 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/tokenizer_code_map.py +36 -0
- data/vendor/lexbor/version +1 -0
- metadata +542 -0
@@ -0,0 +1,927 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2020 Alexander Borisov
|
3
|
+
*
|
4
|
+
* Author: Alexander Borisov <borisov@lexbor.com>
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include "lexbor/core/serialize.h"
|
8
|
+
#include "lexbor/css/selectors/selectors.h"
|
9
|
+
#include "lexbor/css/selectors/selector.h"
|
10
|
+
#include "lexbor/css/selectors/pseudo.h"
|
11
|
+
#include "lexbor/css/selectors/pseudo_const.h"
|
12
|
+
#include "lexbor/css/selectors/pseudo_state.h"
|
13
|
+
#include "lexbor/css/selectors/state.h"
|
14
|
+
#include "lexbor/css/selectors/pseudo_res.h"
|
15
|
+
|
16
|
+
|
17
|
+
typedef void
|
18
|
+
(*lxb_css_selector_destroy_f)(lxb_css_selector_t *selector,
|
19
|
+
lxb_css_selectors_memory_t *mem);
|
20
|
+
typedef lxb_status_t
|
21
|
+
(*lxb_css_selector_serialize_f)(lxb_css_selector_t *selector,
|
22
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
23
|
+
|
24
|
+
|
25
|
+
static void
|
26
|
+
lxb_css_selector_destroy_undef(lxb_css_selector_t *selector,
|
27
|
+
lxb_css_selectors_memory_t *mem);
|
28
|
+
static void
|
29
|
+
lxb_css_selector_destroy_any(lxb_css_selector_t *selector,
|
30
|
+
lxb_css_selectors_memory_t *mem);
|
31
|
+
static void
|
32
|
+
lxb_css_selector_destroy_id(lxb_css_selector_t *selector,
|
33
|
+
lxb_css_selectors_memory_t *mem);
|
34
|
+
static void
|
35
|
+
lxb_css_selector_destroy_attribute(lxb_css_selector_t *selector,
|
36
|
+
lxb_css_selectors_memory_t *mem);
|
37
|
+
static void
|
38
|
+
lxb_css_selector_destroy_pseudo_class_function(lxb_css_selector_t *selector,
|
39
|
+
lxb_css_selectors_memory_t *mem);
|
40
|
+
static void
|
41
|
+
lxb_css_selector_destroy_pseudo_element_function(lxb_css_selector_t *selector,
|
42
|
+
lxb_css_selectors_memory_t *mem);
|
43
|
+
|
44
|
+
static lxb_status_t
|
45
|
+
lxb_css_selector_serialize_undef(lxb_css_selector_t *selector,
|
46
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
47
|
+
static lxb_status_t
|
48
|
+
lxb_css_selector_serialize_any(lxb_css_selector_t *selector,
|
49
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
50
|
+
static lxb_status_t
|
51
|
+
lxb_css_selector_serialize_id(lxb_css_selector_t *selector,
|
52
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
53
|
+
static lxb_status_t
|
54
|
+
lxb_css_selector_serialize_class(lxb_css_selector_t *selector,
|
55
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
56
|
+
static lxb_status_t
|
57
|
+
lxb_css_selector_serialize_attribute(lxb_css_selector_t *selector,
|
58
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
59
|
+
static lxb_status_t
|
60
|
+
lxb_css_selector_serialize_pseudo_class(lxb_css_selector_t *selector,
|
61
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
62
|
+
static lxb_status_t
|
63
|
+
lxb_css_selector_serialize_pseudo_class_function(lxb_css_selector_t *selector,
|
64
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
65
|
+
static lxb_status_t
|
66
|
+
lxb_css_selector_serialize_pseudo_element(lxb_css_selector_t *selector,
|
67
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
68
|
+
static lxb_status_t
|
69
|
+
lxb_css_selector_serialize_pseudo_element_function(lxb_css_selector_t *selector,
|
70
|
+
lexbor_serialize_cb_f cb, void *ctx);
|
71
|
+
|
72
|
+
static lxb_status_t
|
73
|
+
lxb_css_selector_serialize_pseudo_single(lxb_css_selector_t *selector,
|
74
|
+
lexbor_serialize_cb_f cb, void *ctx,
|
75
|
+
bool is_class);
|
76
|
+
|
77
|
+
|
78
|
+
static const lxb_css_selector_destroy_f
|
79
|
+
lxb_selector_destroy_map[LXB_CSS_SELECTOR_TYPE__LAST_ENTRY] =
|
80
|
+
{
|
81
|
+
lxb_css_selector_destroy_undef,
|
82
|
+
lxb_css_selector_destroy_any,
|
83
|
+
lxb_css_selector_destroy_any,
|
84
|
+
lxb_css_selector_destroy_id,
|
85
|
+
lxb_css_selector_destroy_id,
|
86
|
+
lxb_css_selector_destroy_attribute,
|
87
|
+
lxb_css_selector_destroy_undef,
|
88
|
+
lxb_css_selector_destroy_pseudo_class_function,
|
89
|
+
lxb_css_selector_destroy_undef,
|
90
|
+
lxb_css_selector_destroy_pseudo_element_function
|
91
|
+
};
|
92
|
+
|
93
|
+
static const lxb_css_selector_serialize_f
|
94
|
+
lxb_selector_serialize_map[LXB_CSS_SELECTOR_TYPE__LAST_ENTRY] =
|
95
|
+
{
|
96
|
+
lxb_css_selector_serialize_undef,
|
97
|
+
lxb_css_selector_serialize_any,
|
98
|
+
lxb_css_selector_serialize_any,
|
99
|
+
lxb_css_selector_serialize_id,
|
100
|
+
lxb_css_selector_serialize_class,
|
101
|
+
lxb_css_selector_serialize_attribute,
|
102
|
+
lxb_css_selector_serialize_pseudo_class,
|
103
|
+
lxb_css_selector_serialize_pseudo_class_function,
|
104
|
+
lxb_css_selector_serialize_pseudo_element,
|
105
|
+
lxb_css_selector_serialize_pseudo_element_function
|
106
|
+
};
|
107
|
+
|
108
|
+
|
109
|
+
lxb_css_selector_t *
|
110
|
+
lxb_css_selector_create(lxb_css_selector_list_t *list)
|
111
|
+
{
|
112
|
+
lxb_css_selector_t *selector = lexbor_dobject_calloc(list->memory->objs);
|
113
|
+
if (selector == NULL) {
|
114
|
+
return NULL;
|
115
|
+
}
|
116
|
+
|
117
|
+
selector->list = list;
|
118
|
+
|
119
|
+
return selector;
|
120
|
+
}
|
121
|
+
|
122
|
+
void
|
123
|
+
lxb_css_selector_destroy(lxb_css_selector_t *selector)
|
124
|
+
{
|
125
|
+
lxb_css_selectors_memory_t *memory;
|
126
|
+
|
127
|
+
if (selector != NULL) {
|
128
|
+
memory = selector->list->memory;
|
129
|
+
|
130
|
+
lxb_selector_destroy_map[selector->type](selector, memory);
|
131
|
+
lexbor_dobject_free(memory->objs, selector);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
void
|
136
|
+
lxb_css_selector_destroy_chain(lxb_css_selector_t *selector)
|
137
|
+
{
|
138
|
+
lxb_css_selector_t *next;
|
139
|
+
|
140
|
+
while (selector != NULL) {
|
141
|
+
next = selector->next;
|
142
|
+
lxb_css_selector_destroy(selector);
|
143
|
+
selector = next;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
lxb_css_selector_list_t *
|
148
|
+
lxb_css_selector_list_create(lxb_css_selectors_memory_t *mem)
|
149
|
+
{
|
150
|
+
lxb_css_selector_list_t *list;
|
151
|
+
|
152
|
+
list = lexbor_dobject_calloc(mem->objs);
|
153
|
+
if (list == NULL) {
|
154
|
+
return NULL;
|
155
|
+
}
|
156
|
+
|
157
|
+
list->memory = mem;
|
158
|
+
|
159
|
+
return list;
|
160
|
+
}
|
161
|
+
|
162
|
+
void
|
163
|
+
lxb_css_selector_list_remove(lxb_css_selector_list_t *list)
|
164
|
+
{
|
165
|
+
if (list->next != NULL) {
|
166
|
+
list->next->prev = list->prev;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (list->prev != NULL) {
|
170
|
+
list->prev->next = list->next;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
void
|
175
|
+
lxb_css_selector_list_selectors_remove(lxb_css_selectors_t *selectors,
|
176
|
+
lxb_css_selector_list_t *list)
|
177
|
+
{
|
178
|
+
lxb_css_selector_list_remove(list);
|
179
|
+
|
180
|
+
if (selectors->list == list) {
|
181
|
+
selectors->list = list->next;
|
182
|
+
}
|
183
|
+
|
184
|
+
if (selectors->list_last == list) {
|
185
|
+
selectors->list_last = list->prev;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
void
|
190
|
+
lxb_css_selector_list_destroy(lxb_css_selector_list_t *list)
|
191
|
+
{
|
192
|
+
if (list != NULL) {
|
193
|
+
lxb_css_selector_destroy_chain(list->first);
|
194
|
+
lexbor_dobject_free(list->memory->objs, list);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
void
|
199
|
+
lxb_css_selector_list_destroy_chain(lxb_css_selector_list_t *list)
|
200
|
+
{
|
201
|
+
lxb_css_selector_list_t *next;
|
202
|
+
|
203
|
+
while (list != NULL) {
|
204
|
+
next = list->next;
|
205
|
+
lxb_css_selector_list_destroy(list);
|
206
|
+
list = next;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
void
|
211
|
+
lxb_css_selector_list_destroy_memory(lxb_css_selector_list_t *list)
|
212
|
+
{
|
213
|
+
lxb_css_selectors_memory_t *mem;
|
214
|
+
|
215
|
+
if (list != NULL) {
|
216
|
+
mem = list->memory;
|
217
|
+
|
218
|
+
(void) lexbor_dobject_destroy(mem->objs, true);
|
219
|
+
(void) lexbor_mraw_destroy(mem->mraw, true);
|
220
|
+
(void) lexbor_free(mem);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
static void
|
225
|
+
lxb_css_selector_destroy_undef(lxb_css_selector_t *selector,
|
226
|
+
lxb_css_selectors_memory_t *mem)
|
227
|
+
{
|
228
|
+
/* Do nothing. */
|
229
|
+
}
|
230
|
+
|
231
|
+
static void
|
232
|
+
lxb_css_selector_destroy_any(lxb_css_selector_t *selector,
|
233
|
+
lxb_css_selectors_memory_t *mem)
|
234
|
+
{
|
235
|
+
if (selector->ns.data != NULL) {
|
236
|
+
lexbor_mraw_free(mem->mraw, selector->ns.data);
|
237
|
+
}
|
238
|
+
|
239
|
+
if (selector->name.data != NULL) {
|
240
|
+
lexbor_mraw_free(mem->mraw, selector->name.data);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
static void
|
245
|
+
lxb_css_selector_destroy_id(lxb_css_selector_t *selector,
|
246
|
+
lxb_css_selectors_memory_t *mem)
|
247
|
+
{
|
248
|
+
if (selector->name.data != NULL) {
|
249
|
+
(void) lexbor_mraw_free(mem->mraw, selector->name.data);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
static void
|
254
|
+
lxb_css_selector_destroy_attribute(lxb_css_selector_t *selector,
|
255
|
+
lxb_css_selectors_memory_t *mem)
|
256
|
+
{
|
257
|
+
if (selector->ns.data != NULL) {
|
258
|
+
lexbor_mraw_free(mem->mraw, selector->ns.data);
|
259
|
+
}
|
260
|
+
|
261
|
+
if (selector->name.data != NULL) {
|
262
|
+
lexbor_mraw_free(mem->mraw, selector->name.data);
|
263
|
+
}
|
264
|
+
|
265
|
+
if (selector->u.attribute.value.data != NULL) {
|
266
|
+
lexbor_mraw_free(mem->mraw, selector->u.attribute.value.data);
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
static void
|
271
|
+
lxb_css_selector_destroy_pseudo_class_function(lxb_css_selector_t *selector,
|
272
|
+
lxb_css_selectors_memory_t *mem)
|
273
|
+
{
|
274
|
+
lxb_css_selector_anb_of_t *anbof;
|
275
|
+
lxb_css_selector_pseudo_t *pseudo;
|
276
|
+
|
277
|
+
pseudo = &selector->u.pseudo;
|
278
|
+
|
279
|
+
switch (pseudo->type) {
|
280
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_CURRENT:
|
281
|
+
break;
|
282
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_DIR:
|
283
|
+
break;
|
284
|
+
|
285
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_HAS:
|
286
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_IS:
|
287
|
+
lxb_css_selector_list_destroy_chain(pseudo->data);
|
288
|
+
break;
|
289
|
+
|
290
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_LANG:
|
291
|
+
break;
|
292
|
+
|
293
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NOT:
|
294
|
+
lxb_css_selector_list_destroy_chain(pseudo->data);
|
295
|
+
break;
|
296
|
+
|
297
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_CHILD:
|
298
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_COL:
|
299
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_LAST_CHILD:
|
300
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_LAST_COL:
|
301
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_LAST_OF_TYPE:
|
302
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_OF_TYPE:
|
303
|
+
anbof = pseudo->data;
|
304
|
+
|
305
|
+
if (anbof != NULL) {
|
306
|
+
lxb_css_selector_list_destroy_chain(anbof->of);
|
307
|
+
lexbor_mraw_free(mem->mraw, anbof);
|
308
|
+
}
|
309
|
+
break;
|
310
|
+
|
311
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_WHERE:
|
312
|
+
lxb_css_selector_list_destroy_chain(pseudo->data);
|
313
|
+
break;
|
314
|
+
|
315
|
+
default:
|
316
|
+
break;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
static void
|
321
|
+
lxb_css_selector_destroy_pseudo_element_function(lxb_css_selector_t *selector,
|
322
|
+
lxb_css_selectors_memory_t *mem)
|
323
|
+
{
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
lxb_status_t
|
328
|
+
lxb_css_selector_serialize(lxb_css_selector_t *selector,
|
329
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
330
|
+
{
|
331
|
+
return lxb_selector_serialize_map[selector->type](selector, cb, ctx);
|
332
|
+
}
|
333
|
+
|
334
|
+
lxb_status_t
|
335
|
+
lxb_css_selector_serialize_chain(lxb_css_selector_t *selector,
|
336
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
337
|
+
{
|
338
|
+
size_t length;
|
339
|
+
lxb_char_t *data;
|
340
|
+
lxb_status_t status;
|
341
|
+
|
342
|
+
if (selector == NULL) {
|
343
|
+
return LXB_STATUS_OK;
|
344
|
+
}
|
345
|
+
|
346
|
+
if (selector->combinator > LXB_CSS_SELECTOR_COMBINATOR_CLOSE) {
|
347
|
+
data = lxb_css_selector_combinator(selector, &length);
|
348
|
+
if (data == NULL) {
|
349
|
+
return LXB_STATUS_ERROR_UNEXPECTED_DATA;
|
350
|
+
}
|
351
|
+
|
352
|
+
lxb_css_selector_serialize_write(data, length);
|
353
|
+
lxb_css_selector_serialize_write(" ", 1);
|
354
|
+
}
|
355
|
+
|
356
|
+
status = lxb_css_selector_serialize(selector, cb, ctx);
|
357
|
+
if (status != LXB_STATUS_OK) {
|
358
|
+
return status;
|
359
|
+
}
|
360
|
+
|
361
|
+
selector = selector->next;
|
362
|
+
|
363
|
+
while (selector != NULL) {
|
364
|
+
data = lxb_css_selector_combinator(selector, &length);
|
365
|
+
if (data == NULL) {
|
366
|
+
return LXB_STATUS_ERROR_UNEXPECTED_DATA;
|
367
|
+
}
|
368
|
+
|
369
|
+
if (length != 0) {
|
370
|
+
lxb_css_selector_serialize_write(" ", 1);
|
371
|
+
|
372
|
+
if (*data != ' ') {
|
373
|
+
lxb_css_selector_serialize_write(data, length);
|
374
|
+
lxb_css_selector_serialize_write(" ", 1);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
status = lxb_css_selector_serialize(selector, cb, ctx);
|
379
|
+
if (status != LXB_STATUS_OK) {
|
380
|
+
return status;
|
381
|
+
}
|
382
|
+
|
383
|
+
selector = selector->next;
|
384
|
+
}
|
385
|
+
|
386
|
+
return LXB_STATUS_OK;
|
387
|
+
}
|
388
|
+
|
389
|
+
lxb_char_t *
|
390
|
+
lxb_css_selector_serialize_chain_char(lxb_css_selector_t *selector,
|
391
|
+
size_t *out_length)
|
392
|
+
{
|
393
|
+
size_t length = 0;
|
394
|
+
lxb_status_t status;
|
395
|
+
lexbor_str_t str;
|
396
|
+
|
397
|
+
status = lxb_css_selector_serialize_chain(selector, lexbor_serialize_length_cb,
|
398
|
+
&length);
|
399
|
+
if (status != LXB_STATUS_OK) {
|
400
|
+
goto failed;
|
401
|
+
}
|
402
|
+
|
403
|
+
/* + 1 == '\0' */
|
404
|
+
str.data = lexbor_malloc(length + 1);
|
405
|
+
if (str.data == NULL) {
|
406
|
+
goto failed;
|
407
|
+
}
|
408
|
+
|
409
|
+
str.length = 0;
|
410
|
+
|
411
|
+
status = lxb_css_selector_serialize_chain(selector, lexbor_serialize_copy_cb,
|
412
|
+
&str);
|
413
|
+
if (status != LXB_STATUS_OK) {
|
414
|
+
lexbor_free(str.data);
|
415
|
+
goto failed;
|
416
|
+
}
|
417
|
+
|
418
|
+
str.data[str.length] = '\0';
|
419
|
+
|
420
|
+
if (out_length != NULL) {
|
421
|
+
*out_length = str.length;
|
422
|
+
}
|
423
|
+
|
424
|
+
return str.data;
|
425
|
+
|
426
|
+
failed:
|
427
|
+
|
428
|
+
if (out_length != NULL) {
|
429
|
+
*out_length = 0;
|
430
|
+
}
|
431
|
+
|
432
|
+
return NULL;
|
433
|
+
}
|
434
|
+
|
435
|
+
lxb_status_t
|
436
|
+
lxb_css_selector_serialize_list(lxb_css_selector_list_t *list,
|
437
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
438
|
+
{
|
439
|
+
if (list != NULL) {
|
440
|
+
return lxb_css_selector_serialize_chain(list->first, cb, ctx);
|
441
|
+
}
|
442
|
+
|
443
|
+
return LXB_STATUS_OK;
|
444
|
+
}
|
445
|
+
|
446
|
+
lxb_char_t *
|
447
|
+
lxb_css_selector_serialize_list_char(lxb_css_selector_list_t *list,
|
448
|
+
size_t *out_length)
|
449
|
+
{
|
450
|
+
size_t length = 0;
|
451
|
+
lxb_status_t status;
|
452
|
+
lexbor_str_t str;
|
453
|
+
|
454
|
+
status = lxb_css_selector_serialize_list_chain(list, lexbor_serialize_length_cb,
|
455
|
+
&length);
|
456
|
+
if (status != LXB_STATUS_OK) {
|
457
|
+
goto failed;
|
458
|
+
}
|
459
|
+
|
460
|
+
/* + 1 == '\0' */
|
461
|
+
str.data = lexbor_malloc(length + 1);
|
462
|
+
if (str.data == NULL) {
|
463
|
+
goto failed;
|
464
|
+
}
|
465
|
+
|
466
|
+
str.length = 0;
|
467
|
+
|
468
|
+
status = lxb_css_selector_serialize_list_chain(list, lexbor_serialize_copy_cb,
|
469
|
+
&str);
|
470
|
+
if (status != LXB_STATUS_OK) {
|
471
|
+
lexbor_free(str.data);
|
472
|
+
goto failed;
|
473
|
+
}
|
474
|
+
|
475
|
+
str.data[str.length] = '\0';
|
476
|
+
|
477
|
+
if (out_length != NULL) {
|
478
|
+
*out_length = str.length;
|
479
|
+
}
|
480
|
+
|
481
|
+
return str.data;
|
482
|
+
|
483
|
+
failed:
|
484
|
+
|
485
|
+
if (out_length != NULL) {
|
486
|
+
*out_length = 0;
|
487
|
+
}
|
488
|
+
|
489
|
+
return NULL;
|
490
|
+
}
|
491
|
+
|
492
|
+
lxb_status_t
|
493
|
+
lxb_css_selector_serialize_list_chain(lxb_css_selector_list_t *list,
|
494
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
495
|
+
{
|
496
|
+
lxb_status_t status;
|
497
|
+
|
498
|
+
if (list == NULL) {
|
499
|
+
return LXB_STATUS_OK;
|
500
|
+
}
|
501
|
+
|
502
|
+
status = lxb_css_selector_serialize_chain(list->first, cb, ctx);
|
503
|
+
if (status != LXB_STATUS_OK) {
|
504
|
+
return status;
|
505
|
+
}
|
506
|
+
|
507
|
+
list = list->next;
|
508
|
+
|
509
|
+
while (list != NULL) {
|
510
|
+
lxb_css_selector_serialize_write(", ", 2);
|
511
|
+
|
512
|
+
status = lxb_css_selector_serialize_chain(list->first, cb, ctx);
|
513
|
+
if (status != LXB_STATUS_OK) {
|
514
|
+
return status;
|
515
|
+
}
|
516
|
+
|
517
|
+
list = list->next;
|
518
|
+
}
|
519
|
+
|
520
|
+
return LXB_STATUS_OK;
|
521
|
+
}
|
522
|
+
|
523
|
+
lxb_char_t *
|
524
|
+
lxb_css_selector_serialize_list_chain_char(lxb_css_selector_list_t *list,
|
525
|
+
size_t *out_length)
|
526
|
+
{
|
527
|
+
size_t length = 0;
|
528
|
+
lxb_status_t status;
|
529
|
+
lexbor_str_t str;
|
530
|
+
|
531
|
+
status = lxb_css_selector_serialize_list_chain(list, lexbor_serialize_length_cb,
|
532
|
+
&length);
|
533
|
+
if (status != LXB_STATUS_OK) {
|
534
|
+
goto failed;
|
535
|
+
}
|
536
|
+
|
537
|
+
/* + 1 == '\0' */
|
538
|
+
str.data = lexbor_malloc(length + 1);
|
539
|
+
if (str.data == NULL) {
|
540
|
+
goto failed;
|
541
|
+
}
|
542
|
+
|
543
|
+
str.length = 0;
|
544
|
+
|
545
|
+
status = lxb_css_selector_serialize_list_chain(list, lexbor_serialize_copy_cb,
|
546
|
+
&str);
|
547
|
+
if (status != LXB_STATUS_OK) {
|
548
|
+
lexbor_free(str.data);
|
549
|
+
goto failed;
|
550
|
+
}
|
551
|
+
|
552
|
+
str.data[str.length] = '\0';
|
553
|
+
|
554
|
+
if (out_length != NULL) {
|
555
|
+
*out_length = str.length;
|
556
|
+
}
|
557
|
+
|
558
|
+
return str.data;
|
559
|
+
|
560
|
+
failed:
|
561
|
+
|
562
|
+
if (out_length != NULL) {
|
563
|
+
*out_length = 0;
|
564
|
+
}
|
565
|
+
|
566
|
+
return NULL;
|
567
|
+
}
|
568
|
+
|
569
|
+
|
570
|
+
static lxb_status_t
|
571
|
+
lxb_css_selector_serialize_undef(lxb_css_selector_t *selector,
|
572
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
573
|
+
{
|
574
|
+
return LXB_STATUS_ERROR_UNEXPECTED_DATA;
|
575
|
+
}
|
576
|
+
|
577
|
+
static lxb_status_t
|
578
|
+
lxb_css_selector_serialize_any(lxb_css_selector_t *selector,
|
579
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
580
|
+
{
|
581
|
+
lxb_status_t status;
|
582
|
+
|
583
|
+
if (selector->ns.data != NULL) {
|
584
|
+
lxb_css_selector_serialize_write(selector->ns.data,
|
585
|
+
selector->ns.length);
|
586
|
+
lxb_css_selector_serialize_write("|", 1);
|
587
|
+
}
|
588
|
+
|
589
|
+
if (selector->name.data != NULL) {
|
590
|
+
return cb(selector->name.data, selector->name.length, ctx);
|
591
|
+
}
|
592
|
+
|
593
|
+
return LXB_STATUS_OK;
|
594
|
+
}
|
595
|
+
|
596
|
+
static lxb_status_t
|
597
|
+
lxb_css_selector_serialize_id(lxb_css_selector_t *selector,
|
598
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
599
|
+
{
|
600
|
+
lxb_status_t status;
|
601
|
+
|
602
|
+
lxb_css_selector_serialize_write("#", 1);
|
603
|
+
|
604
|
+
if (selector->name.data != NULL) {
|
605
|
+
return cb(selector->name.data, selector->name.length, ctx);
|
606
|
+
}
|
607
|
+
|
608
|
+
return LXB_STATUS_OK;
|
609
|
+
}
|
610
|
+
|
611
|
+
static lxb_status_t
|
612
|
+
lxb_css_selector_serialize_class(lxb_css_selector_t *selector,
|
613
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
614
|
+
{
|
615
|
+
lxb_status_t status;
|
616
|
+
|
617
|
+
lxb_css_selector_serialize_write(".", 1);
|
618
|
+
|
619
|
+
if (selector->name.data != NULL) {
|
620
|
+
return cb(selector->name.data, selector->name.length, ctx);
|
621
|
+
}
|
622
|
+
|
623
|
+
return LXB_STATUS_OK;
|
624
|
+
}
|
625
|
+
|
626
|
+
static lxb_status_t
|
627
|
+
lxb_css_selector_serialize_attribute(lxb_css_selector_t *selector,
|
628
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
629
|
+
{
|
630
|
+
lxb_char_t *p, *begin, *end;
|
631
|
+
lxb_status_t status;
|
632
|
+
lxb_css_selector_attribute_t *attr;
|
633
|
+
|
634
|
+
lxb_css_selector_serialize_write("[", 1);
|
635
|
+
|
636
|
+
status = lxb_css_selector_serialize_any(selector, cb, ctx);
|
637
|
+
if (status != LXB_STATUS_OK) {
|
638
|
+
return status;
|
639
|
+
}
|
640
|
+
|
641
|
+
attr = &selector->u.attribute;
|
642
|
+
|
643
|
+
if (attr->value.data == NULL) {
|
644
|
+
return cb((lxb_char_t *) "]", 1, ctx);
|
645
|
+
}
|
646
|
+
|
647
|
+
switch (attr->match) {
|
648
|
+
case LXB_CSS_SELECTOR_MATCH_EQUAL:
|
649
|
+
lxb_css_selector_serialize_write("=", 1);
|
650
|
+
break;
|
651
|
+
case LXB_CSS_SELECTOR_MATCH_INCLUDE:
|
652
|
+
lxb_css_selector_serialize_write("~=", 2);
|
653
|
+
break;
|
654
|
+
case LXB_CSS_SELECTOR_MATCH_DASH:
|
655
|
+
lxb_css_selector_serialize_write("|=", 2);
|
656
|
+
break;
|
657
|
+
case LXB_CSS_SELECTOR_MATCH_PREFIX:
|
658
|
+
lxb_css_selector_serialize_write("^=", 2);
|
659
|
+
break;
|
660
|
+
case LXB_CSS_SELECTOR_MATCH_SUFFIX:
|
661
|
+
lxb_css_selector_serialize_write("$=", 2);
|
662
|
+
break;
|
663
|
+
case LXB_CSS_SELECTOR_MATCH_SUBSTRING:
|
664
|
+
lxb_css_selector_serialize_write("*=", 2);
|
665
|
+
break;
|
666
|
+
|
667
|
+
default:
|
668
|
+
return LXB_STATUS_ERROR_UNEXPECTED_DATA;
|
669
|
+
}
|
670
|
+
|
671
|
+
p = attr->value.data;
|
672
|
+
end = attr->value.data + attr->value.length;
|
673
|
+
|
674
|
+
begin = p;
|
675
|
+
|
676
|
+
lxb_css_selector_serialize_write("\"", 1);
|
677
|
+
|
678
|
+
while (p < end) {
|
679
|
+
if (*p == '"') {
|
680
|
+
if (begin < p) {
|
681
|
+
lxb_css_selector_serialize_write(begin, p - begin);
|
682
|
+
}
|
683
|
+
|
684
|
+
lxb_css_selector_serialize_write("\\000022", 7);
|
685
|
+
|
686
|
+
begin = p + 1;
|
687
|
+
}
|
688
|
+
|
689
|
+
p++;
|
690
|
+
}
|
691
|
+
|
692
|
+
if (begin < p) {
|
693
|
+
lxb_css_selector_serialize_write(begin, p - begin);
|
694
|
+
}
|
695
|
+
|
696
|
+
lxb_css_selector_serialize_write("\"", 1);
|
697
|
+
|
698
|
+
if (attr->modifier != LXB_CSS_SELECTOR_MODIFIER_UNSET) {
|
699
|
+
switch (attr->modifier) {
|
700
|
+
case LXB_CSS_SELECTOR_MODIFIER_I:
|
701
|
+
lxb_css_selector_serialize_write("i", 1);
|
702
|
+
break;
|
703
|
+
|
704
|
+
case LXB_CSS_SELECTOR_MODIFIER_S:
|
705
|
+
lxb_css_selector_serialize_write("s", 1);
|
706
|
+
break;
|
707
|
+
|
708
|
+
default:
|
709
|
+
return LXB_STATUS_ERROR_UNEXPECTED_DATA;
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
return cb((lxb_char_t *) "]", 1, ctx);
|
714
|
+
}
|
715
|
+
|
716
|
+
static lxb_status_t
|
717
|
+
lxb_css_selector_serialize_pseudo_class(lxb_css_selector_t *selector,
|
718
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
719
|
+
{
|
720
|
+
return lxb_css_selector_serialize_pseudo_single(selector, cb, ctx, true);
|
721
|
+
}
|
722
|
+
|
723
|
+
static lxb_status_t
|
724
|
+
lxb_css_selector_serialize_pseudo_class_function(lxb_css_selector_t *selector,
|
725
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
726
|
+
{
|
727
|
+
lxb_status_t status;
|
728
|
+
lxb_css_selector_pseudo_t *pseudo;
|
729
|
+
const lxb_css_selectors_pseudo_data_func_t *pfunc;
|
730
|
+
|
731
|
+
pseudo = &selector->u.pseudo;
|
732
|
+
|
733
|
+
pfunc = &lxb_css_selectors_pseudo_data_pseudo_class_function[pseudo->type];
|
734
|
+
|
735
|
+
lxb_css_selector_serialize_write(":", 1);
|
736
|
+
lxb_css_selector_serialize_write(pfunc->name, pfunc->length);
|
737
|
+
lxb_css_selector_serialize_write("(", 1);
|
738
|
+
|
739
|
+
switch (pseudo->type) {
|
740
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_CURRENT:
|
741
|
+
break;
|
742
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_DIR:
|
743
|
+
break;
|
744
|
+
|
745
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_HAS:
|
746
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_IS:
|
747
|
+
status = lxb_css_selector_serialize_list_chain(pseudo->data,
|
748
|
+
cb, ctx);
|
749
|
+
break;
|
750
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_LANG:
|
751
|
+
break;
|
752
|
+
|
753
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NOT:
|
754
|
+
status = lxb_css_selector_serialize_list_chain(pseudo->data,
|
755
|
+
cb, ctx);
|
756
|
+
break;
|
757
|
+
|
758
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_CHILD:
|
759
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_COL:
|
760
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_LAST_CHILD:
|
761
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_LAST_COL:
|
762
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_LAST_OF_TYPE:
|
763
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_NTH_OF_TYPE:
|
764
|
+
status = LXB_STATUS_OK;
|
765
|
+
|
766
|
+
if (pseudo->data != NULL) {
|
767
|
+
status = lxb_css_selector_serialize_anb_of(pseudo->data,
|
768
|
+
cb, ctx);
|
769
|
+
}
|
770
|
+
break;
|
771
|
+
|
772
|
+
case LXB_CSS_SELECTOR_PSEUDO_CLASS_FUNCTION_WHERE:
|
773
|
+
status = lxb_css_selector_serialize_list_chain(pseudo->data,
|
774
|
+
cb, ctx);
|
775
|
+
break;
|
776
|
+
|
777
|
+
default:
|
778
|
+
status = LXB_STATUS_OK;
|
779
|
+
break;
|
780
|
+
}
|
781
|
+
|
782
|
+
if (status != LXB_STATUS_OK) {
|
783
|
+
return status;
|
784
|
+
}
|
785
|
+
|
786
|
+
lxb_css_selector_serialize_write(")", 1);
|
787
|
+
|
788
|
+
return LXB_STATUS_OK;
|
789
|
+
}
|
790
|
+
|
791
|
+
static lxb_status_t
|
792
|
+
lxb_css_selector_serialize_pseudo_element(lxb_css_selector_t *selector,
|
793
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
794
|
+
{
|
795
|
+
return lxb_css_selector_serialize_pseudo_single(selector, cb, ctx, false);
|
796
|
+
}
|
797
|
+
|
798
|
+
static lxb_status_t
|
799
|
+
lxb_css_selector_serialize_pseudo_element_function(lxb_css_selector_t *selector,
|
800
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
801
|
+
{
|
802
|
+
return LXB_STATUS_OK;
|
803
|
+
}
|
804
|
+
|
805
|
+
static lxb_status_t
|
806
|
+
lxb_css_selector_serialize_pseudo_single(lxb_css_selector_t *selector,
|
807
|
+
lexbor_serialize_cb_f cb, void *ctx,
|
808
|
+
bool is_class)
|
809
|
+
{
|
810
|
+
lxb_status_t status;
|
811
|
+
lxb_css_selector_pseudo_t *pseudo;
|
812
|
+
const lxb_css_selectors_pseudo_data_t *pclass;
|
813
|
+
|
814
|
+
pseudo = &selector->u.pseudo;
|
815
|
+
|
816
|
+
if (is_class) {
|
817
|
+
pclass = &lxb_css_selectors_pseudo_data_pseudo_class[pseudo->type];
|
818
|
+
lxb_css_selector_serialize_write(":", 1);
|
819
|
+
}
|
820
|
+
else {
|
821
|
+
pclass = &lxb_css_selectors_pseudo_data_pseudo_element[pseudo->type];
|
822
|
+
lxb_css_selector_serialize_write("::", 2);
|
823
|
+
}
|
824
|
+
|
825
|
+
lxb_css_selector_serialize_write(pclass->name, pclass->length);
|
826
|
+
|
827
|
+
return LXB_STATUS_OK;
|
828
|
+
}
|
829
|
+
|
830
|
+
lxb_status_t
|
831
|
+
lxb_css_selector_serialize_anb_of(lxb_css_selector_anb_of_t *anbof,
|
832
|
+
lexbor_serialize_cb_f cb, void *ctx)
|
833
|
+
{
|
834
|
+
lxb_status_t status;
|
835
|
+
|
836
|
+
static const lxb_char_t of[] = " of ";
|
837
|
+
|
838
|
+
status = lxb_css_syntax_anb_serialize(&anbof->anb, cb, ctx);
|
839
|
+
if (status != LXB_STATUS_OK) {
|
840
|
+
return status;
|
841
|
+
}
|
842
|
+
|
843
|
+
if (anbof->of != NULL) {
|
844
|
+
lxb_css_selector_serialize_write(of, sizeof(of) - 1);
|
845
|
+
|
846
|
+
return lxb_css_selector_serialize_list_chain(anbof->of, cb, ctx);
|
847
|
+
}
|
848
|
+
|
849
|
+
return LXB_STATUS_OK;
|
850
|
+
}
|
851
|
+
|
852
|
+
lxb_char_t *
|
853
|
+
lxb_css_selector_combinator(lxb_css_selector_t *selector, size_t *out_length)
|
854
|
+
{
|
855
|
+
switch (selector->combinator) {
|
856
|
+
case LXB_CSS_SELECTOR_COMBINATOR_DESCENDANT:
|
857
|
+
if (out_length != NULL) {*out_length = 1;}
|
858
|
+
return (lxb_char_t *) " ";
|
859
|
+
|
860
|
+
case LXB_CSS_SELECTOR_COMBINATOR_CLOSE:
|
861
|
+
if (out_length != NULL) {*out_length = 0;}
|
862
|
+
return (lxb_char_t *) "";
|
863
|
+
|
864
|
+
case LXB_CSS_SELECTOR_COMBINATOR_CHILD:
|
865
|
+
if (out_length != NULL) {*out_length = 1;}
|
866
|
+
return (lxb_char_t *) ">";
|
867
|
+
|
868
|
+
case LXB_CSS_SELECTOR_COMBINATOR_SIBLING:
|
869
|
+
if (out_length != NULL) {*out_length = 1;}
|
870
|
+
return (lxb_char_t *) "+";
|
871
|
+
|
872
|
+
case LXB_CSS_SELECTOR_COMBINATOR_FOLLOWING:
|
873
|
+
if (out_length != NULL) {*out_length = 1;}
|
874
|
+
return (lxb_char_t *) "~";
|
875
|
+
|
876
|
+
case LXB_CSS_SELECTOR_COMBINATOR_CELL:
|
877
|
+
if (out_length != NULL) {*out_length = 2;}
|
878
|
+
return (lxb_char_t *) "||";
|
879
|
+
|
880
|
+
default:
|
881
|
+
if (out_length != NULL) {*out_length = 0;}
|
882
|
+
return NULL;
|
883
|
+
}
|
884
|
+
}
|
885
|
+
|
886
|
+
void
|
887
|
+
lxb_css_selector_list_append(lxb_css_selector_list_t *list,
|
888
|
+
lxb_css_selector_t *selector)
|
889
|
+
{
|
890
|
+
selector->prev = list->last;
|
891
|
+
|
892
|
+
if (list->last != NULL) {
|
893
|
+
list->last->next = selector;
|
894
|
+
}
|
895
|
+
else {
|
896
|
+
list->first = selector;
|
897
|
+
}
|
898
|
+
|
899
|
+
list->last = selector;
|
900
|
+
}
|
901
|
+
|
902
|
+
void
|
903
|
+
lxb_css_selector_append_next(lxb_css_selector_t *dist, lxb_css_selector_t *src)
|
904
|
+
{
|
905
|
+
if (dist->next != NULL) {
|
906
|
+
dist->next->prev = src;
|
907
|
+
}
|
908
|
+
|
909
|
+
src->prev = dist;
|
910
|
+
src->next = dist->next;
|
911
|
+
|
912
|
+
dist->next = src;
|
913
|
+
}
|
914
|
+
|
915
|
+
void
|
916
|
+
lxb_css_selector_list_append_next(lxb_css_selector_list_t *dist,
|
917
|
+
lxb_css_selector_list_t *src)
|
918
|
+
{
|
919
|
+
if (dist->next != NULL) {
|
920
|
+
dist->next->prev = src;
|
921
|
+
}
|
922
|
+
|
923
|
+
src->prev = dist;
|
924
|
+
src->next = dist->next;
|
925
|
+
|
926
|
+
dist->next = src;
|
927
|
+
}
|