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,1411 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2018-2021 Alexander Borisov
|
3
|
+
*
|
4
|
+
* Author: Alexander Borisov <borisov@lexbor.com>
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include "lexbor/dom/interfaces/element.h"
|
8
|
+
#include "lexbor/dom/interfaces/attr.h"
|
9
|
+
#include "lexbor/tag/tag.h"
|
10
|
+
#include "lexbor/ns/ns.h"
|
11
|
+
|
12
|
+
#include "lexbor/core/str.h"
|
13
|
+
#include "lexbor/core/utils.h"
|
14
|
+
#include "lexbor/core/hash.h"
|
15
|
+
|
16
|
+
|
17
|
+
typedef struct lxb_dom_element_cb_ctx lxb_dom_element_cb_ctx_t;
|
18
|
+
|
19
|
+
typedef bool
|
20
|
+
(*lxb_dom_element_attr_cmp_f)(lxb_dom_element_cb_ctx_t *ctx,
|
21
|
+
lxb_dom_attr_t *attr);
|
22
|
+
|
23
|
+
|
24
|
+
struct lxb_dom_element_cb_ctx {
|
25
|
+
lxb_dom_collection_t *col;
|
26
|
+
lxb_status_t status;
|
27
|
+
lxb_dom_element_attr_cmp_f cmp_func;
|
28
|
+
|
29
|
+
lxb_dom_attr_id_t name_id;
|
30
|
+
lxb_ns_prefix_id_t prefix_id;
|
31
|
+
|
32
|
+
const lxb_char_t *value;
|
33
|
+
size_t value_length;
|
34
|
+
};
|
35
|
+
|
36
|
+
|
37
|
+
static lexbor_action_t
|
38
|
+
lxb_dom_elements_by_tag_name_cb(lxb_dom_node_t *node, void *ctx);
|
39
|
+
|
40
|
+
static lexbor_action_t
|
41
|
+
lxb_dom_elements_by_tag_name_cb_all(lxb_dom_node_t *node, void *ctx);
|
42
|
+
|
43
|
+
static lexbor_action_t
|
44
|
+
lxb_dom_elements_by_class_name_cb(lxb_dom_node_t *node, void *ctx);
|
45
|
+
|
46
|
+
static lexbor_action_t
|
47
|
+
lxb_dom_elements_by_attr_cb(lxb_dom_node_t *node, void *ctx);
|
48
|
+
|
49
|
+
static bool
|
50
|
+
lxb_dom_elements_by_attr_cmp_full(lxb_dom_element_cb_ctx_t *ctx,
|
51
|
+
lxb_dom_attr_t *attr);
|
52
|
+
|
53
|
+
static bool
|
54
|
+
lxb_dom_elements_by_attr_cmp_full_case(lxb_dom_element_cb_ctx_t *ctx,
|
55
|
+
lxb_dom_attr_t *attr);
|
56
|
+
|
57
|
+
static bool
|
58
|
+
lxb_dom_elements_by_attr_cmp_begin(lxb_dom_element_cb_ctx_t *ctx,
|
59
|
+
lxb_dom_attr_t *attr);
|
60
|
+
|
61
|
+
static bool
|
62
|
+
lxb_dom_elements_by_attr_cmp_begin_case(lxb_dom_element_cb_ctx_t *ctx,
|
63
|
+
lxb_dom_attr_t *attr);
|
64
|
+
|
65
|
+
static bool
|
66
|
+
lxb_dom_elements_by_attr_cmp_end(lxb_dom_element_cb_ctx_t *ctx,
|
67
|
+
lxb_dom_attr_t *attr);
|
68
|
+
|
69
|
+
static bool
|
70
|
+
lxb_dom_elements_by_attr_cmp_end_case(lxb_dom_element_cb_ctx_t *ctx,
|
71
|
+
lxb_dom_attr_t *attr);
|
72
|
+
|
73
|
+
static bool
|
74
|
+
lxb_dom_elements_by_attr_cmp_contain(lxb_dom_element_cb_ctx_t *ctx,
|
75
|
+
lxb_dom_attr_t *attr);
|
76
|
+
|
77
|
+
static bool
|
78
|
+
lxb_dom_elements_by_attr_cmp_contain_case(lxb_dom_element_cb_ctx_t *ctx,
|
79
|
+
lxb_dom_attr_t *attr);
|
80
|
+
|
81
|
+
static const lxb_char_t *
|
82
|
+
lxb_dom_element_upper_update(lxb_dom_element_t *element, size_t *len);
|
83
|
+
|
84
|
+
const lxb_tag_data_t *
|
85
|
+
lxb_tag_append(lexbor_hash_t *hash, lxb_tag_id_t tag_id,
|
86
|
+
const lxb_char_t *name, size_t length);
|
87
|
+
|
88
|
+
const lxb_tag_data_t *
|
89
|
+
lxb_tag_append_lower(lexbor_hash_t *hash,
|
90
|
+
const lxb_char_t *name, size_t length);
|
91
|
+
|
92
|
+
const lxb_ns_data_t *
|
93
|
+
lxb_ns_append(lexbor_hash_t *hash, const lxb_char_t *link, size_t length);
|
94
|
+
|
95
|
+
|
96
|
+
lxb_dom_element_t *
|
97
|
+
lxb_dom_element_interface_create(lxb_dom_document_t *document)
|
98
|
+
{
|
99
|
+
lxb_dom_element_t *element;
|
100
|
+
|
101
|
+
element = lexbor_mraw_calloc(document->mraw,
|
102
|
+
sizeof(lxb_dom_element_t));
|
103
|
+
if (element == NULL) {
|
104
|
+
return NULL;
|
105
|
+
}
|
106
|
+
|
107
|
+
lxb_dom_node_t *node = lxb_dom_interface_node(element);
|
108
|
+
|
109
|
+
node->owner_document = lxb_dom_document_owner(document);
|
110
|
+
node->type = LXB_DOM_NODE_TYPE_ELEMENT;
|
111
|
+
|
112
|
+
return element;
|
113
|
+
}
|
114
|
+
|
115
|
+
lxb_dom_element_t *
|
116
|
+
lxb_dom_element_interface_clone(lxb_dom_document_t *document,
|
117
|
+
const lxb_dom_element_t *element)
|
118
|
+
{
|
119
|
+
lxb_dom_element_t *new;
|
120
|
+
|
121
|
+
new = lxb_dom_element_interface_create(document);
|
122
|
+
if (new == NULL) {
|
123
|
+
return NULL;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (lxb_dom_element_interface_copy(new, element) != LXB_STATUS_OK) {
|
127
|
+
return lxb_dom_element_interface_destroy(new);
|
128
|
+
}
|
129
|
+
|
130
|
+
return new;
|
131
|
+
}
|
132
|
+
|
133
|
+
lxb_dom_element_t *
|
134
|
+
lxb_dom_element_interface_destroy(lxb_dom_element_t *element)
|
135
|
+
{
|
136
|
+
lxb_dom_attr_t *attr_next;
|
137
|
+
lxb_dom_attr_t *attr = element->first_attr;
|
138
|
+
|
139
|
+
while (attr != NULL) {
|
140
|
+
attr_next = attr->next;
|
141
|
+
|
142
|
+
lxb_dom_attr_interface_destroy(attr);
|
143
|
+
|
144
|
+
attr = attr_next;
|
145
|
+
}
|
146
|
+
|
147
|
+
(void) lxb_dom_node_interface_destroy(lxb_dom_interface_node(element));
|
148
|
+
|
149
|
+
return NULL;
|
150
|
+
}
|
151
|
+
|
152
|
+
lxb_status_t
|
153
|
+
lxb_dom_element_interface_copy(lxb_dom_element_t *dst,
|
154
|
+
const lxb_dom_element_t *src)
|
155
|
+
{
|
156
|
+
lxb_status_t status;
|
157
|
+
lxb_dom_document_t *document;
|
158
|
+
lxb_dom_attr_t *attr, *clone;
|
159
|
+
|
160
|
+
status = lxb_dom_node_interface_copy(&dst->node, &src->node, false);
|
161
|
+
if (status != LXB_STATUS_OK) {
|
162
|
+
return status;
|
163
|
+
}
|
164
|
+
|
165
|
+
document = lxb_dom_interface_node(dst)->owner_document;
|
166
|
+
attr = src->first_attr;
|
167
|
+
|
168
|
+
while (attr != NULL) {
|
169
|
+
clone = lxb_dom_attr_interface_clone(document, attr);
|
170
|
+
if (clone == NULL) {
|
171
|
+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
|
172
|
+
}
|
173
|
+
|
174
|
+
(void) lxb_dom_element_attr_append(dst, clone);
|
175
|
+
|
176
|
+
attr = attr->next;
|
177
|
+
}
|
178
|
+
|
179
|
+
return LXB_STATUS_OK;
|
180
|
+
}
|
181
|
+
|
182
|
+
LXB_API lxb_status_t
|
183
|
+
lxb_dom_element_qualified_name_set(lxb_dom_element_t *element,
|
184
|
+
const lxb_char_t *prefix, size_t prefix_len,
|
185
|
+
const lxb_char_t *lname, size_t lname_len)
|
186
|
+
{
|
187
|
+
lxb_char_t *key = (lxb_char_t *) lname;
|
188
|
+
const lxb_tag_data_t *tag_data;
|
189
|
+
|
190
|
+
if (prefix != NULL && prefix_len != 0) {
|
191
|
+
key = lexbor_malloc(prefix_len + lname_len + 2);
|
192
|
+
if (key == NULL) {
|
193
|
+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
|
194
|
+
}
|
195
|
+
|
196
|
+
memcpy(key, prefix, prefix_len);
|
197
|
+
memcpy(&key[prefix_len + 1], lname, lname_len);
|
198
|
+
|
199
|
+
lname_len = prefix_len + lname_len + 1;
|
200
|
+
|
201
|
+
key[prefix_len] = ':';
|
202
|
+
key[lname_len] = '\0';
|
203
|
+
}
|
204
|
+
|
205
|
+
tag_data = lxb_tag_append(element->node.owner_document->tags,
|
206
|
+
element->node.local_name, key, lname_len);
|
207
|
+
if (tag_data == NULL) {
|
208
|
+
return LXB_STATUS_ERROR;
|
209
|
+
}
|
210
|
+
|
211
|
+
element->qualified_name = (lxb_tag_id_t) tag_data;
|
212
|
+
|
213
|
+
return LXB_STATUS_OK;
|
214
|
+
}
|
215
|
+
|
216
|
+
lxb_dom_element_t *
|
217
|
+
lxb_dom_element_create(lxb_dom_document_t *document,
|
218
|
+
const lxb_char_t *local_name, size_t lname_len,
|
219
|
+
const lxb_char_t *ns_link, size_t ns_len,
|
220
|
+
const lxb_char_t *prefix, size_t prefix_len,
|
221
|
+
const lxb_char_t *is, size_t is_len,
|
222
|
+
bool sync_custom)
|
223
|
+
{
|
224
|
+
lxb_status_t status;
|
225
|
+
const lxb_ns_data_t *ns_data;
|
226
|
+
const lxb_tag_data_t *tag_data;
|
227
|
+
const lxb_ns_prefix_data_t *ns_prefix;
|
228
|
+
lxb_dom_element_t *element;
|
229
|
+
|
230
|
+
/* TODO: Must implement custom elements */
|
231
|
+
|
232
|
+
/* 7. Otherwise */
|
233
|
+
|
234
|
+
ns_data = NULL;
|
235
|
+
tag_data = NULL;
|
236
|
+
ns_prefix = NULL;
|
237
|
+
|
238
|
+
tag_data = lxb_tag_append_lower(document->tags, local_name, lname_len);
|
239
|
+
if (tag_data == NULL) {
|
240
|
+
return NULL;
|
241
|
+
}
|
242
|
+
|
243
|
+
if (ns_link != NULL) {
|
244
|
+
ns_data = lxb_ns_append(document->ns, ns_link, ns_len);
|
245
|
+
}
|
246
|
+
else {
|
247
|
+
ns_data = lxb_ns_data_by_id(document->ns, LXB_NS__UNDEF);
|
248
|
+
}
|
249
|
+
|
250
|
+
if (ns_data == NULL) {
|
251
|
+
return NULL;
|
252
|
+
}
|
253
|
+
|
254
|
+
element = lxb_dom_document_create_interface(document, tag_data->tag_id,
|
255
|
+
ns_data->ns_id);
|
256
|
+
if (element == NULL) {
|
257
|
+
return NULL;
|
258
|
+
}
|
259
|
+
|
260
|
+
if (prefix != NULL) {
|
261
|
+
ns_prefix = lxb_ns_prefix_append(document->prefix, prefix, prefix_len);
|
262
|
+
if (ns_prefix == NULL) {
|
263
|
+
return lxb_dom_document_destroy_interface(element);
|
264
|
+
}
|
265
|
+
|
266
|
+
element->node.prefix = ns_prefix->prefix_id;
|
267
|
+
|
268
|
+
status = lxb_dom_element_qualified_name_set(element, prefix, prefix_len,
|
269
|
+
local_name, lname_len);
|
270
|
+
if (status != LXB_STATUS_OK) {
|
271
|
+
return lxb_dom_document_destroy_interface(element);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
if (is_len != 0) {
|
276
|
+
status = lxb_dom_element_is_set(element, is, is_len);
|
277
|
+
if (status != LXB_STATUS_OK) {
|
278
|
+
return lxb_dom_document_destroy_interface(element);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
element->node.local_name = tag_data->tag_id;
|
283
|
+
element->node.ns = ns_data->ns_id;
|
284
|
+
|
285
|
+
if (ns_data->ns_id == LXB_NS_HTML && is_len != 0) {
|
286
|
+
element->custom_state = LXB_DOM_ELEMENT_CUSTOM_STATE_UNDEFINED;
|
287
|
+
}
|
288
|
+
else {
|
289
|
+
element->custom_state = LXB_DOM_ELEMENT_CUSTOM_STATE_UNCUSTOMIZED;
|
290
|
+
}
|
291
|
+
|
292
|
+
return element;
|
293
|
+
}
|
294
|
+
|
295
|
+
lxb_dom_element_t *
|
296
|
+
lxb_dom_element_destroy(lxb_dom_element_t *element)
|
297
|
+
{
|
298
|
+
return lxb_dom_document_destroy_interface(element);
|
299
|
+
}
|
300
|
+
|
301
|
+
bool
|
302
|
+
lxb_dom_element_has_attributes(lxb_dom_element_t *element)
|
303
|
+
{
|
304
|
+
return element->first_attr != NULL;
|
305
|
+
}
|
306
|
+
|
307
|
+
lxb_dom_attr_t *
|
308
|
+
lxb_dom_element_set_attribute(lxb_dom_element_t *element,
|
309
|
+
const lxb_char_t *qualified_name, size_t qn_len,
|
310
|
+
const lxb_char_t *value, size_t value_len)
|
311
|
+
{
|
312
|
+
lxb_status_t status;
|
313
|
+
lxb_dom_attr_t *attr;
|
314
|
+
|
315
|
+
attr = lxb_dom_element_attr_is_exist(element, qualified_name, qn_len);
|
316
|
+
|
317
|
+
if (attr != NULL) {
|
318
|
+
status = lxb_dom_attr_set_value(attr, value, value_len);
|
319
|
+
if (status != LXB_STATUS_OK) {
|
320
|
+
return lxb_dom_attr_interface_destroy(attr);
|
321
|
+
}
|
322
|
+
|
323
|
+
return attr;
|
324
|
+
}
|
325
|
+
|
326
|
+
attr = lxb_dom_attr_interface_create(element->node.owner_document);
|
327
|
+
if (attr == NULL) {
|
328
|
+
return NULL;
|
329
|
+
}
|
330
|
+
|
331
|
+
if (element->node.ns == LXB_NS_HTML
|
332
|
+
&& element->node.owner_document->type == LXB_DOM_DOCUMENT_DTYPE_HTML)
|
333
|
+
{
|
334
|
+
status = lxb_dom_attr_set_name(attr, qualified_name, qn_len, true);
|
335
|
+
}
|
336
|
+
else {
|
337
|
+
status = lxb_dom_attr_set_name(attr, qualified_name, qn_len, false);
|
338
|
+
}
|
339
|
+
|
340
|
+
if (status != LXB_STATUS_OK) {
|
341
|
+
return lxb_dom_attr_interface_destroy(attr);
|
342
|
+
}
|
343
|
+
|
344
|
+
status = lxb_dom_attr_set_value(attr, value, value_len);
|
345
|
+
if (status != LXB_STATUS_OK) {
|
346
|
+
return lxb_dom_attr_interface_destroy(attr);
|
347
|
+
}
|
348
|
+
|
349
|
+
lxb_dom_element_attr_append(element, attr);
|
350
|
+
|
351
|
+
return attr;
|
352
|
+
}
|
353
|
+
|
354
|
+
const lxb_char_t *
|
355
|
+
lxb_dom_element_get_attribute(lxb_dom_element_t *element,
|
356
|
+
const lxb_char_t *qualified_name, size_t qn_len,
|
357
|
+
size_t *value_len)
|
358
|
+
{
|
359
|
+
lxb_dom_attr_t *attr;
|
360
|
+
|
361
|
+
attr = lxb_dom_element_attr_by_name(element, qualified_name, qn_len);
|
362
|
+
if (attr == NULL) {
|
363
|
+
if (value_len != NULL) {
|
364
|
+
*value_len = 0;
|
365
|
+
}
|
366
|
+
|
367
|
+
return NULL;
|
368
|
+
}
|
369
|
+
|
370
|
+
return lxb_dom_attr_value(attr, value_len);
|
371
|
+
}
|
372
|
+
|
373
|
+
lxb_status_t
|
374
|
+
lxb_dom_element_remove_attribute(lxb_dom_element_t *element,
|
375
|
+
const lxb_char_t *qualified_name, size_t qn_len)
|
376
|
+
{
|
377
|
+
lxb_status_t status;
|
378
|
+
lxb_dom_attr_t *attr;
|
379
|
+
|
380
|
+
attr = lxb_dom_element_attr_by_name(element, qualified_name, qn_len);
|
381
|
+
if (attr == NULL) {
|
382
|
+
return LXB_STATUS_OK;
|
383
|
+
}
|
384
|
+
|
385
|
+
status = lxb_dom_element_attr_remove(element, attr);
|
386
|
+
if (status != LXB_STATUS_OK) {
|
387
|
+
return status;
|
388
|
+
}
|
389
|
+
|
390
|
+
lxb_dom_attr_interface_destroy(attr);
|
391
|
+
|
392
|
+
return LXB_STATUS_OK;
|
393
|
+
}
|
394
|
+
|
395
|
+
bool
|
396
|
+
lxb_dom_element_has_attribute(lxb_dom_element_t *element,
|
397
|
+
const lxb_char_t *qualified_name, size_t qn_len)
|
398
|
+
{
|
399
|
+
return lxb_dom_element_attr_by_name(element, qualified_name, qn_len) != NULL;
|
400
|
+
}
|
401
|
+
|
402
|
+
lxb_status_t
|
403
|
+
lxb_dom_element_attr_append(lxb_dom_element_t *element, lxb_dom_attr_t *attr)
|
404
|
+
{
|
405
|
+
lxb_dom_attr_t *exist;
|
406
|
+
|
407
|
+
if (attr->node.local_name == LXB_DOM_ATTR_ID) {
|
408
|
+
exist = element->attr_id;
|
409
|
+
|
410
|
+
if (exist != NULL) {
|
411
|
+
lxb_dom_element_attr_remove(element, exist);
|
412
|
+
lxb_dom_attr_interface_destroy(exist);
|
413
|
+
}
|
414
|
+
|
415
|
+
element->attr_id = attr;
|
416
|
+
}
|
417
|
+
else if (attr->node.local_name == LXB_DOM_ATTR_CLASS) {
|
418
|
+
exist = element->attr_class;
|
419
|
+
|
420
|
+
if (exist != NULL) {
|
421
|
+
lxb_dom_element_attr_remove(element, exist);
|
422
|
+
lxb_dom_attr_interface_destroy(exist);
|
423
|
+
}
|
424
|
+
|
425
|
+
element->attr_class = attr;
|
426
|
+
}
|
427
|
+
|
428
|
+
if (element->first_attr == NULL) {
|
429
|
+
element->first_attr = attr;
|
430
|
+
element->last_attr = attr;
|
431
|
+
|
432
|
+
return LXB_STATUS_OK;
|
433
|
+
}
|
434
|
+
|
435
|
+
attr->prev = element->last_attr;
|
436
|
+
element->last_attr->next = attr;
|
437
|
+
|
438
|
+
element->last_attr = attr;
|
439
|
+
|
440
|
+
return LXB_STATUS_OK;
|
441
|
+
}
|
442
|
+
|
443
|
+
lxb_status_t
|
444
|
+
lxb_dom_element_attr_remove(lxb_dom_element_t *element, lxb_dom_attr_t *attr)
|
445
|
+
{
|
446
|
+
if (element->attr_id == attr) {
|
447
|
+
element->attr_id = NULL;
|
448
|
+
}
|
449
|
+
else if (element->attr_class == attr) {
|
450
|
+
element->attr_class = NULL;
|
451
|
+
}
|
452
|
+
|
453
|
+
if (attr->prev != NULL) {
|
454
|
+
attr->prev->next = attr->next;
|
455
|
+
}
|
456
|
+
else {
|
457
|
+
element->first_attr = attr->next;
|
458
|
+
}
|
459
|
+
|
460
|
+
if (attr->next != NULL) {
|
461
|
+
attr->next->prev = attr->prev;
|
462
|
+
}
|
463
|
+
else {
|
464
|
+
element->last_attr = attr->prev;
|
465
|
+
}
|
466
|
+
|
467
|
+
attr->next = NULL;
|
468
|
+
attr->prev = NULL;
|
469
|
+
|
470
|
+
return LXB_STATUS_OK;
|
471
|
+
}
|
472
|
+
|
473
|
+
lxb_dom_attr_t *
|
474
|
+
lxb_dom_element_attr_by_name(lxb_dom_element_t *element,
|
475
|
+
const lxb_char_t *qualified_name, size_t length)
|
476
|
+
{
|
477
|
+
const lxb_dom_attr_data_t *data;
|
478
|
+
lexbor_hash_t *attrs = element->node.owner_document->attrs;
|
479
|
+
lxb_dom_attr_t *attr = element->first_attr;
|
480
|
+
|
481
|
+
if (element->node.ns == LXB_NS_HTML
|
482
|
+
&& element->node.owner_document->type == LXB_DOM_DOCUMENT_DTYPE_HTML)
|
483
|
+
{
|
484
|
+
data = lxb_dom_attr_data_by_local_name(attrs, qualified_name, length);
|
485
|
+
}
|
486
|
+
else {
|
487
|
+
data = lxb_dom_attr_data_by_qualified_name(attrs, qualified_name,
|
488
|
+
length);
|
489
|
+
}
|
490
|
+
|
491
|
+
if (data == NULL) {
|
492
|
+
return NULL;
|
493
|
+
}
|
494
|
+
|
495
|
+
while (attr != NULL) {
|
496
|
+
if (attr->node.local_name == data->attr_id
|
497
|
+
|| attr->qualified_name == data->attr_id)
|
498
|
+
{
|
499
|
+
return attr;
|
500
|
+
}
|
501
|
+
|
502
|
+
attr = attr->next;
|
503
|
+
}
|
504
|
+
|
505
|
+
return NULL;
|
506
|
+
}
|
507
|
+
|
508
|
+
lxb_dom_attr_t *
|
509
|
+
lxb_dom_element_attr_by_local_name_data(lxb_dom_element_t *element,
|
510
|
+
const lxb_dom_attr_data_t *data)
|
511
|
+
{
|
512
|
+
lxb_dom_attr_t *attr = element->first_attr;
|
513
|
+
|
514
|
+
while (attr != NULL) {
|
515
|
+
if (attr->node.local_name == data->attr_id) {
|
516
|
+
return attr;
|
517
|
+
}
|
518
|
+
|
519
|
+
attr = attr->next;
|
520
|
+
}
|
521
|
+
|
522
|
+
return NULL;
|
523
|
+
}
|
524
|
+
|
525
|
+
lxb_dom_attr_t *
|
526
|
+
lxb_dom_element_attr_by_id(lxb_dom_element_t *element,
|
527
|
+
lxb_dom_attr_id_t attr_id)
|
528
|
+
{
|
529
|
+
lxb_dom_attr_t *attr = element->first_attr;
|
530
|
+
|
531
|
+
while (attr != NULL) {
|
532
|
+
if (attr->node.local_name == attr_id) {
|
533
|
+
return attr;
|
534
|
+
}
|
535
|
+
|
536
|
+
attr = attr->next;
|
537
|
+
}
|
538
|
+
|
539
|
+
return NULL;
|
540
|
+
}
|
541
|
+
|
542
|
+
bool
|
543
|
+
lxb_dom_element_compare(lxb_dom_element_t *first, lxb_dom_element_t *second)
|
544
|
+
{
|
545
|
+
lxb_dom_attr_t *f_attr = first->first_attr;
|
546
|
+
lxb_dom_attr_t *s_attr = second->first_attr;
|
547
|
+
|
548
|
+
if (first->node.local_name != second->node.local_name
|
549
|
+
|| first->node.ns != second->node.ns
|
550
|
+
|| first->qualified_name != second->qualified_name)
|
551
|
+
{
|
552
|
+
return false;
|
553
|
+
}
|
554
|
+
|
555
|
+
/* Compare attr counts */
|
556
|
+
while (f_attr != NULL && s_attr != NULL) {
|
557
|
+
f_attr = f_attr->next;
|
558
|
+
s_attr = s_attr->next;
|
559
|
+
}
|
560
|
+
|
561
|
+
if (f_attr != NULL || s_attr != NULL) {
|
562
|
+
return false;
|
563
|
+
}
|
564
|
+
|
565
|
+
/* Compare attr */
|
566
|
+
f_attr = first->first_attr;
|
567
|
+
|
568
|
+
while (f_attr != NULL) {
|
569
|
+
s_attr = second->first_attr;
|
570
|
+
|
571
|
+
while (s_attr != NULL) {
|
572
|
+
if (lxb_dom_attr_compare(f_attr, s_attr)) {
|
573
|
+
break;
|
574
|
+
}
|
575
|
+
|
576
|
+
s_attr = s_attr->next;
|
577
|
+
}
|
578
|
+
|
579
|
+
if (s_attr == NULL) {
|
580
|
+
return false;
|
581
|
+
}
|
582
|
+
|
583
|
+
f_attr = f_attr->next;
|
584
|
+
}
|
585
|
+
|
586
|
+
return true;
|
587
|
+
}
|
588
|
+
|
589
|
+
lxb_dom_attr_t *
|
590
|
+
lxb_dom_element_attr_is_exist(lxb_dom_element_t *element,
|
591
|
+
const lxb_char_t *qualified_name, size_t length)
|
592
|
+
{
|
593
|
+
const lxb_dom_attr_data_t *data;
|
594
|
+
lxb_dom_attr_t *attr = element->first_attr;
|
595
|
+
|
596
|
+
data = lxb_dom_attr_data_by_local_name(element->node.owner_document->attrs,
|
597
|
+
qualified_name, length);
|
598
|
+
if (data == NULL) {
|
599
|
+
return NULL;
|
600
|
+
}
|
601
|
+
|
602
|
+
while (attr != NULL) {
|
603
|
+
if (attr->node.local_name == data->attr_id
|
604
|
+
|| attr->qualified_name == data->attr_id)
|
605
|
+
{
|
606
|
+
return attr;
|
607
|
+
}
|
608
|
+
|
609
|
+
attr = attr->next;
|
610
|
+
}
|
611
|
+
|
612
|
+
return NULL;
|
613
|
+
}
|
614
|
+
|
615
|
+
lxb_status_t
|
616
|
+
lxb_dom_element_is_set(lxb_dom_element_t *element,
|
617
|
+
const lxb_char_t *is, size_t is_len)
|
618
|
+
{
|
619
|
+
if (element->is_value == NULL) {
|
620
|
+
element->is_value = lexbor_mraw_calloc(element->node.owner_document->mraw,
|
621
|
+
sizeof(lexbor_str_t));
|
622
|
+
if (element->is_value == NULL) {
|
623
|
+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
if (element->is_value->data == NULL) {
|
628
|
+
lexbor_str_init(element->is_value,
|
629
|
+
element->node.owner_document->text, is_len);
|
630
|
+
|
631
|
+
if (element->is_value->data == NULL) {
|
632
|
+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
|
633
|
+
}
|
634
|
+
}
|
635
|
+
|
636
|
+
if (element->is_value->length != 0) {
|
637
|
+
element->is_value->length = 0;
|
638
|
+
}
|
639
|
+
|
640
|
+
lxb_char_t *data = lexbor_str_append(element->is_value,
|
641
|
+
element->node.owner_document->text,
|
642
|
+
is, is_len);
|
643
|
+
if (data == NULL) {
|
644
|
+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
|
645
|
+
}
|
646
|
+
|
647
|
+
return LXB_STATUS_OK;
|
648
|
+
}
|
649
|
+
|
650
|
+
lxb_inline lxb_status_t
|
651
|
+
lxb_dom_element_prepare_by_attr(lxb_dom_document_t *document,
|
652
|
+
lxb_dom_element_cb_ctx_t *cb_ctx,
|
653
|
+
const lxb_char_t *qname, size_t qlen)
|
654
|
+
{
|
655
|
+
size_t length;
|
656
|
+
const lxb_char_t *prefix_end;
|
657
|
+
const lxb_dom_attr_data_t *attr_data;
|
658
|
+
const lxb_ns_prefix_data_t *prefix_data;
|
659
|
+
|
660
|
+
cb_ctx->prefix_id = LXB_NS__UNDEF;
|
661
|
+
|
662
|
+
prefix_end = memchr(qname, ':', qlen);
|
663
|
+
|
664
|
+
if (prefix_end != NULL) {
|
665
|
+
length = prefix_end - qname;
|
666
|
+
|
667
|
+
if (length == 0) {
|
668
|
+
return LXB_STATUS_ERROR_WRONG_ARGS;
|
669
|
+
}
|
670
|
+
|
671
|
+
prefix_data = lxb_ns_prefix_data_by_name(document->prefix, qname, qlen);
|
672
|
+
if (prefix_data == NULL) {
|
673
|
+
return LXB_STATUS_STOP;
|
674
|
+
}
|
675
|
+
|
676
|
+
cb_ctx->prefix_id = prefix_data->prefix_id;
|
677
|
+
|
678
|
+
length += 1;
|
679
|
+
|
680
|
+
if (length >= qlen) {
|
681
|
+
return LXB_STATUS_ERROR_WRONG_ARGS;
|
682
|
+
}
|
683
|
+
|
684
|
+
qname += length;
|
685
|
+
qlen -= length;
|
686
|
+
}
|
687
|
+
|
688
|
+
attr_data = lxb_dom_attr_data_by_local_name(document->attrs, qname, qlen);
|
689
|
+
if (attr_data == NULL) {
|
690
|
+
return LXB_STATUS_STOP;
|
691
|
+
}
|
692
|
+
|
693
|
+
cb_ctx->name_id = attr_data->attr_id;
|
694
|
+
|
695
|
+
return LXB_STATUS_OK;
|
696
|
+
}
|
697
|
+
|
698
|
+
lxb_inline lxb_status_t
|
699
|
+
lxb_dom_element_prepare_by(lxb_dom_document_t *document,
|
700
|
+
lxb_dom_element_cb_ctx_t *cb_ctx,
|
701
|
+
const lxb_char_t *qname, size_t qlen)
|
702
|
+
{
|
703
|
+
size_t length;
|
704
|
+
const lxb_char_t *prefix_end;
|
705
|
+
const lxb_tag_data_t *tag_data;
|
706
|
+
const lxb_ns_prefix_data_t *prefix_data;
|
707
|
+
|
708
|
+
cb_ctx->prefix_id = LXB_NS__UNDEF;
|
709
|
+
|
710
|
+
prefix_end = memchr(qname, ':', qlen);
|
711
|
+
|
712
|
+
if (prefix_end != NULL) {
|
713
|
+
length = prefix_end - qname;
|
714
|
+
|
715
|
+
if (length == 0) {
|
716
|
+
return LXB_STATUS_ERROR_WRONG_ARGS;
|
717
|
+
}
|
718
|
+
|
719
|
+
prefix_data = lxb_ns_prefix_data_by_name(document->prefix, qname, qlen);
|
720
|
+
if (prefix_data == NULL) {
|
721
|
+
return LXB_STATUS_STOP;
|
722
|
+
}
|
723
|
+
|
724
|
+
cb_ctx->prefix_id = prefix_data->prefix_id;
|
725
|
+
|
726
|
+
length += 1;
|
727
|
+
|
728
|
+
if (length >= qlen) {
|
729
|
+
return LXB_STATUS_ERROR_WRONG_ARGS;
|
730
|
+
}
|
731
|
+
|
732
|
+
qname += length;
|
733
|
+
qlen -= length;
|
734
|
+
}
|
735
|
+
|
736
|
+
tag_data = lxb_tag_data_by_name(document->tags, qname, qlen);
|
737
|
+
if (tag_data == NULL) {
|
738
|
+
return LXB_STATUS_STOP;
|
739
|
+
}
|
740
|
+
|
741
|
+
cb_ctx->name_id = tag_data->tag_id;
|
742
|
+
|
743
|
+
return LXB_STATUS_OK;
|
744
|
+
}
|
745
|
+
|
746
|
+
lxb_status_t
|
747
|
+
lxb_dom_elements_by_tag_name(lxb_dom_element_t *root,
|
748
|
+
lxb_dom_collection_t *collection,
|
749
|
+
const lxb_char_t *qualified_name, size_t len)
|
750
|
+
{
|
751
|
+
lxb_status_t status;
|
752
|
+
lxb_dom_element_cb_ctx_t cb_ctx = {0};
|
753
|
+
|
754
|
+
cb_ctx.col = collection;
|
755
|
+
|
756
|
+
/* "*" (U+002A) */
|
757
|
+
if (len == 1 && *qualified_name == 0x2A) {
|
758
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
759
|
+
lxb_dom_elements_by_tag_name_cb_all, &cb_ctx);
|
760
|
+
|
761
|
+
return cb_ctx.status;
|
762
|
+
}
|
763
|
+
|
764
|
+
status = lxb_dom_element_prepare_by(root->node.owner_document,
|
765
|
+
&cb_ctx, qualified_name, len);
|
766
|
+
if (status != LXB_STATUS_OK) {
|
767
|
+
if (status == LXB_STATUS_STOP) {
|
768
|
+
return LXB_STATUS_OK;
|
769
|
+
}
|
770
|
+
|
771
|
+
return status;
|
772
|
+
}
|
773
|
+
|
774
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
775
|
+
lxb_dom_elements_by_tag_name_cb, &cb_ctx);
|
776
|
+
|
777
|
+
return cb_ctx.status;
|
778
|
+
}
|
779
|
+
|
780
|
+
static lexbor_action_t
|
781
|
+
lxb_dom_elements_by_tag_name_cb_all(lxb_dom_node_t *node, void *ctx)
|
782
|
+
{
|
783
|
+
if (node->type != LXB_DOM_NODE_TYPE_ELEMENT) {
|
784
|
+
return LEXBOR_ACTION_OK;
|
785
|
+
}
|
786
|
+
|
787
|
+
lxb_dom_element_cb_ctx_t *cb_ctx = ctx;
|
788
|
+
|
789
|
+
cb_ctx->status = lxb_dom_collection_append(cb_ctx->col, node);
|
790
|
+
if (cb_ctx->status != LXB_STATUS_OK) {
|
791
|
+
return LEXBOR_ACTION_STOP;
|
792
|
+
}
|
793
|
+
|
794
|
+
return LEXBOR_ACTION_OK;
|
795
|
+
}
|
796
|
+
|
797
|
+
static lexbor_action_t
|
798
|
+
lxb_dom_elements_by_tag_name_cb(lxb_dom_node_t *node, void *ctx)
|
799
|
+
{
|
800
|
+
if (node->type != LXB_DOM_NODE_TYPE_ELEMENT) {
|
801
|
+
return LEXBOR_ACTION_OK;
|
802
|
+
}
|
803
|
+
|
804
|
+
lxb_dom_element_cb_ctx_t *cb_ctx = ctx;
|
805
|
+
|
806
|
+
if (node->local_name == cb_ctx->name_id
|
807
|
+
&& node->prefix == cb_ctx->prefix_id)
|
808
|
+
{
|
809
|
+
cb_ctx->status = lxb_dom_collection_append(cb_ctx->col, node);
|
810
|
+
if (cb_ctx->status != LXB_STATUS_OK) {
|
811
|
+
return LEXBOR_ACTION_STOP;
|
812
|
+
}
|
813
|
+
}
|
814
|
+
|
815
|
+
return LEXBOR_ACTION_OK;
|
816
|
+
}
|
817
|
+
|
818
|
+
lxb_status_t
|
819
|
+
lxb_dom_elements_by_class_name(lxb_dom_element_t *root,
|
820
|
+
lxb_dom_collection_t *collection,
|
821
|
+
const lxb_char_t *class_name, size_t len)
|
822
|
+
{
|
823
|
+
if (class_name == NULL || len == 0) {
|
824
|
+
return LXB_STATUS_OK;
|
825
|
+
}
|
826
|
+
|
827
|
+
lxb_dom_element_cb_ctx_t cb_ctx = {0};
|
828
|
+
|
829
|
+
cb_ctx.col = collection;
|
830
|
+
cb_ctx.value = class_name;
|
831
|
+
cb_ctx.value_length = len;
|
832
|
+
|
833
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
834
|
+
lxb_dom_elements_by_class_name_cb, &cb_ctx);
|
835
|
+
|
836
|
+
return cb_ctx.status;
|
837
|
+
}
|
838
|
+
|
839
|
+
static lexbor_action_t
|
840
|
+
lxb_dom_elements_by_class_name_cb(lxb_dom_node_t *node, void *ctx)
|
841
|
+
{
|
842
|
+
if (node->type != LXB_DOM_NODE_TYPE_ELEMENT) {
|
843
|
+
return LEXBOR_ACTION_OK;
|
844
|
+
}
|
845
|
+
|
846
|
+
lxb_dom_element_cb_ctx_t *cb_ctx = ctx;
|
847
|
+
lxb_dom_element_t *el = lxb_dom_interface_element(node);
|
848
|
+
|
849
|
+
if (el->attr_class == NULL
|
850
|
+
|| el->attr_class->value == NULL
|
851
|
+
|| el->attr_class->value->length < cb_ctx->value_length)
|
852
|
+
{
|
853
|
+
return LEXBOR_ACTION_OK;
|
854
|
+
}
|
855
|
+
|
856
|
+
const lxb_char_t *data = el->attr_class->value->data;
|
857
|
+
size_t length = el->attr_class->value->length;
|
858
|
+
|
859
|
+
bool is_it = false;
|
860
|
+
const lxb_char_t *pos = data;
|
861
|
+
const lxb_char_t *end = data + length;
|
862
|
+
|
863
|
+
lxb_dom_document_t *doc = el->node.owner_document;
|
864
|
+
|
865
|
+
for (; data < end; data++) {
|
866
|
+
if (lexbor_utils_whitespace(*data, ==, ||)) {
|
867
|
+
|
868
|
+
if (pos != data && (data - pos) == cb_ctx->value_length) {
|
869
|
+
if (doc->compat_mode == LXB_DOM_DOCUMENT_CMODE_QUIRKS) {
|
870
|
+
is_it = lexbor_str_data_ncasecmp(pos, cb_ctx->value,
|
871
|
+
cb_ctx->value_length);
|
872
|
+
}
|
873
|
+
else {
|
874
|
+
is_it = lexbor_str_data_ncmp(pos, cb_ctx->value,
|
875
|
+
cb_ctx->value_length);
|
876
|
+
}
|
877
|
+
|
878
|
+
if (is_it) {
|
879
|
+
cb_ctx->status = lxb_dom_collection_append(cb_ctx->col,
|
880
|
+
node);
|
881
|
+
if (cb_ctx->status != LXB_STATUS_OK) {
|
882
|
+
return LEXBOR_ACTION_STOP;
|
883
|
+
}
|
884
|
+
|
885
|
+
return LEXBOR_ACTION_OK;
|
886
|
+
}
|
887
|
+
}
|
888
|
+
|
889
|
+
if ((size_t) (end - data) < cb_ctx->value_length) {
|
890
|
+
return LEXBOR_ACTION_OK;
|
891
|
+
}
|
892
|
+
|
893
|
+
pos = data + 1;
|
894
|
+
}
|
895
|
+
}
|
896
|
+
|
897
|
+
if ((end - pos) == cb_ctx->value_length) {
|
898
|
+
if (doc->compat_mode == LXB_DOM_DOCUMENT_CMODE_QUIRKS) {
|
899
|
+
is_it = lexbor_str_data_ncasecmp(pos, cb_ctx->value,
|
900
|
+
cb_ctx->value_length);
|
901
|
+
}
|
902
|
+
else {
|
903
|
+
is_it = lexbor_str_data_ncmp(pos, cb_ctx->value,
|
904
|
+
cb_ctx->value_length);
|
905
|
+
}
|
906
|
+
|
907
|
+
if (is_it) {
|
908
|
+
cb_ctx->status = lxb_dom_collection_append(cb_ctx->col, node);
|
909
|
+
if (cb_ctx->status != LXB_STATUS_OK) {
|
910
|
+
return LEXBOR_ACTION_STOP;
|
911
|
+
}
|
912
|
+
}
|
913
|
+
}
|
914
|
+
|
915
|
+
return LEXBOR_ACTION_OK;
|
916
|
+
}
|
917
|
+
|
918
|
+
lxb_status_t
|
919
|
+
lxb_dom_elements_by_attr(lxb_dom_element_t *root,
|
920
|
+
lxb_dom_collection_t *collection,
|
921
|
+
const lxb_char_t *qualified_name, size_t qname_len,
|
922
|
+
const lxb_char_t *value, size_t value_len,
|
923
|
+
bool case_insensitive)
|
924
|
+
{
|
925
|
+
lxb_status_t status;
|
926
|
+
lxb_dom_element_cb_ctx_t cb_ctx = {0};
|
927
|
+
|
928
|
+
cb_ctx.col = collection;
|
929
|
+
cb_ctx.value = value;
|
930
|
+
cb_ctx.value_length = value_len;
|
931
|
+
|
932
|
+
status = lxb_dom_element_prepare_by_attr(root->node.owner_document,
|
933
|
+
&cb_ctx, qualified_name, qname_len);
|
934
|
+
if (status != LXB_STATUS_OK) {
|
935
|
+
if (status == LXB_STATUS_STOP) {
|
936
|
+
return LXB_STATUS_OK;
|
937
|
+
}
|
938
|
+
|
939
|
+
return status;
|
940
|
+
}
|
941
|
+
|
942
|
+
if (case_insensitive) {
|
943
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_full_case;
|
944
|
+
}
|
945
|
+
else {
|
946
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_full;
|
947
|
+
}
|
948
|
+
|
949
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
950
|
+
lxb_dom_elements_by_attr_cb, &cb_ctx);
|
951
|
+
|
952
|
+
return cb_ctx.status;
|
953
|
+
}
|
954
|
+
|
955
|
+
lxb_status_t
|
956
|
+
lxb_dom_elements_by_attr_begin(lxb_dom_element_t *root,
|
957
|
+
lxb_dom_collection_t *collection,
|
958
|
+
const lxb_char_t *qualified_name, size_t qname_len,
|
959
|
+
const lxb_char_t *value, size_t value_len,
|
960
|
+
bool case_insensitive)
|
961
|
+
{
|
962
|
+
lxb_status_t status;
|
963
|
+
lxb_dom_element_cb_ctx_t cb_ctx = {0};
|
964
|
+
|
965
|
+
cb_ctx.col = collection;
|
966
|
+
cb_ctx.value = value;
|
967
|
+
cb_ctx.value_length = value_len;
|
968
|
+
|
969
|
+
status = lxb_dom_element_prepare_by_attr(root->node.owner_document,
|
970
|
+
&cb_ctx, qualified_name, qname_len);
|
971
|
+
if (status != LXB_STATUS_OK) {
|
972
|
+
if (status == LXB_STATUS_STOP) {
|
973
|
+
return LXB_STATUS_OK;
|
974
|
+
}
|
975
|
+
|
976
|
+
return status;
|
977
|
+
}
|
978
|
+
|
979
|
+
if (case_insensitive) {
|
980
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_begin_case;
|
981
|
+
}
|
982
|
+
else {
|
983
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_begin;
|
984
|
+
}
|
985
|
+
|
986
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
987
|
+
lxb_dom_elements_by_attr_cb, &cb_ctx);
|
988
|
+
|
989
|
+
return cb_ctx.status;
|
990
|
+
}
|
991
|
+
|
992
|
+
lxb_status_t
|
993
|
+
lxb_dom_elements_by_attr_end(lxb_dom_element_t *root,
|
994
|
+
lxb_dom_collection_t *collection,
|
995
|
+
const lxb_char_t *qualified_name, size_t qname_len,
|
996
|
+
const lxb_char_t *value, size_t value_len,
|
997
|
+
bool case_insensitive)
|
998
|
+
{
|
999
|
+
lxb_status_t status;
|
1000
|
+
lxb_dom_element_cb_ctx_t cb_ctx = {0};
|
1001
|
+
|
1002
|
+
cb_ctx.col = collection;
|
1003
|
+
cb_ctx.value = value;
|
1004
|
+
cb_ctx.value_length = value_len;
|
1005
|
+
|
1006
|
+
status = lxb_dom_element_prepare_by_attr(root->node.owner_document,
|
1007
|
+
&cb_ctx, qualified_name, qname_len);
|
1008
|
+
if (status != LXB_STATUS_OK) {
|
1009
|
+
if (status == LXB_STATUS_STOP) {
|
1010
|
+
return LXB_STATUS_OK;
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
return status;
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
if (case_insensitive) {
|
1017
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_end_case;
|
1018
|
+
}
|
1019
|
+
else {
|
1020
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_end;
|
1021
|
+
}
|
1022
|
+
|
1023
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
1024
|
+
lxb_dom_elements_by_attr_cb, &cb_ctx);
|
1025
|
+
|
1026
|
+
return cb_ctx.status;
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
lxb_status_t
|
1030
|
+
lxb_dom_elements_by_attr_contain(lxb_dom_element_t *root,
|
1031
|
+
lxb_dom_collection_t *collection,
|
1032
|
+
const lxb_char_t *qualified_name, size_t qname_len,
|
1033
|
+
const lxb_char_t *value, size_t value_len,
|
1034
|
+
bool case_insensitive)
|
1035
|
+
{
|
1036
|
+
lxb_status_t status;
|
1037
|
+
lxb_dom_element_cb_ctx_t cb_ctx = {0};
|
1038
|
+
|
1039
|
+
cb_ctx.col = collection;
|
1040
|
+
cb_ctx.value = value;
|
1041
|
+
cb_ctx.value_length = value_len;
|
1042
|
+
|
1043
|
+
status = lxb_dom_element_prepare_by_attr(root->node.owner_document,
|
1044
|
+
&cb_ctx, qualified_name, qname_len);
|
1045
|
+
if (status != LXB_STATUS_OK) {
|
1046
|
+
if (status == LXB_STATUS_STOP) {
|
1047
|
+
return LXB_STATUS_OK;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
return status;
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
if (case_insensitive) {
|
1054
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_contain_case;
|
1055
|
+
}
|
1056
|
+
else {
|
1057
|
+
cb_ctx.cmp_func = lxb_dom_elements_by_attr_cmp_contain;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
lxb_dom_node_simple_walk(lxb_dom_interface_node(root),
|
1061
|
+
lxb_dom_elements_by_attr_cb, &cb_ctx);
|
1062
|
+
|
1063
|
+
return cb_ctx.status;
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
static lexbor_action_t
|
1067
|
+
lxb_dom_elements_by_attr_cb(lxb_dom_node_t *node, void *ctx)
|
1068
|
+
{
|
1069
|
+
if (node->type != LXB_DOM_NODE_TYPE_ELEMENT) {
|
1070
|
+
return LEXBOR_ACTION_OK;
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
lxb_dom_attr_t *attr;
|
1074
|
+
lxb_dom_element_cb_ctx_t *cb_ctx = ctx;
|
1075
|
+
lxb_dom_element_t *el = lxb_dom_interface_element(node);
|
1076
|
+
|
1077
|
+
attr = lxb_dom_element_attr_by_id(el, cb_ctx->name_id);
|
1078
|
+
if (attr == NULL) {
|
1079
|
+
return LEXBOR_ACTION_OK;
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
if ((cb_ctx->value_length == 0 && (attr->value == NULL || attr->value->length == 0))
|
1083
|
+
|| cb_ctx->cmp_func(cb_ctx, attr))
|
1084
|
+
{
|
1085
|
+
cb_ctx->status = lxb_dom_collection_append(cb_ctx->col, node);
|
1086
|
+
|
1087
|
+
if (cb_ctx->status != LXB_STATUS_OK) {
|
1088
|
+
return LEXBOR_ACTION_STOP;
|
1089
|
+
}
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
return LEXBOR_ACTION_OK;
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
static bool
|
1096
|
+
lxb_dom_elements_by_attr_cmp_full(lxb_dom_element_cb_ctx_t *ctx,
|
1097
|
+
lxb_dom_attr_t *attr)
|
1098
|
+
{
|
1099
|
+
if (attr->value != NULL && ctx->value_length == attr->value->length
|
1100
|
+
&& lexbor_str_data_ncmp(attr->value->data, ctx->value,
|
1101
|
+
ctx->value_length))
|
1102
|
+
{
|
1103
|
+
return true;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
static bool
|
1110
|
+
lxb_dom_elements_by_attr_cmp_full_case(lxb_dom_element_cb_ctx_t *ctx,
|
1111
|
+
lxb_dom_attr_t *attr)
|
1112
|
+
{
|
1113
|
+
if (attr->value != NULL && ctx->value_length == attr->value->length
|
1114
|
+
&& lexbor_str_data_ncasecmp(attr->value->data, ctx->value,
|
1115
|
+
ctx->value_length))
|
1116
|
+
{
|
1117
|
+
return true;
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
static bool
|
1124
|
+
lxb_dom_elements_by_attr_cmp_begin(lxb_dom_element_cb_ctx_t *ctx,
|
1125
|
+
lxb_dom_attr_t *attr)
|
1126
|
+
{
|
1127
|
+
if (attr->value != NULL && ctx->value_length <= attr->value->length
|
1128
|
+
&& lexbor_str_data_ncmp(attr->value->data, ctx->value,
|
1129
|
+
ctx->value_length))
|
1130
|
+
{
|
1131
|
+
return true;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
static bool
|
1138
|
+
lxb_dom_elements_by_attr_cmp_begin_case(lxb_dom_element_cb_ctx_t *ctx,
|
1139
|
+
lxb_dom_attr_t *attr)
|
1140
|
+
{
|
1141
|
+
if (attr->value != NULL && ctx->value_length <= attr->value->length
|
1142
|
+
&& lexbor_str_data_ncasecmp(attr->value->data,
|
1143
|
+
ctx->value, ctx->value_length))
|
1144
|
+
{
|
1145
|
+
return true;
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
static bool
|
1152
|
+
lxb_dom_elements_by_attr_cmp_end(lxb_dom_element_cb_ctx_t *ctx,
|
1153
|
+
lxb_dom_attr_t *attr)
|
1154
|
+
{
|
1155
|
+
if (attr->value != NULL && ctx->value_length <= attr->value->length) {
|
1156
|
+
size_t dif = attr->value->length - ctx->value_length;
|
1157
|
+
|
1158
|
+
if (lexbor_str_data_ncmp_end(&attr->value->data[dif],
|
1159
|
+
ctx->value, ctx->value_length))
|
1160
|
+
{
|
1161
|
+
return true;
|
1162
|
+
}
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
static bool
|
1169
|
+
lxb_dom_elements_by_attr_cmp_end_case(lxb_dom_element_cb_ctx_t *ctx,
|
1170
|
+
lxb_dom_attr_t *attr)
|
1171
|
+
{
|
1172
|
+
if (attr->value != NULL && ctx->value_length <= attr->value->length) {
|
1173
|
+
size_t dif = attr->value->length - ctx->value_length;
|
1174
|
+
|
1175
|
+
if (lexbor_str_data_ncasecmp_end(&attr->value->data[dif],
|
1176
|
+
ctx->value, ctx->value_length))
|
1177
|
+
{
|
1178
|
+
return true;
|
1179
|
+
}
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
static bool
|
1186
|
+
lxb_dom_elements_by_attr_cmp_contain(lxb_dom_element_cb_ctx_t *ctx,
|
1187
|
+
lxb_dom_attr_t *attr)
|
1188
|
+
{
|
1189
|
+
if (attr->value != NULL && ctx->value_length <= attr->value->length
|
1190
|
+
&& lexbor_str_data_ncmp_contain(attr->value->data, attr->value->length,
|
1191
|
+
ctx->value, ctx->value_length))
|
1192
|
+
{
|
1193
|
+
return true;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
static bool
|
1200
|
+
lxb_dom_elements_by_attr_cmp_contain_case(lxb_dom_element_cb_ctx_t *ctx,
|
1201
|
+
lxb_dom_attr_t *attr)
|
1202
|
+
{
|
1203
|
+
if (attr->value != NULL && ctx->value_length <= attr->value->length
|
1204
|
+
&& lexbor_str_data_ncasecmp_contain(attr->value->data, attr->value->length,
|
1205
|
+
ctx->value, ctx->value_length))
|
1206
|
+
{
|
1207
|
+
return true;
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
return attr->value == NULL && ctx->value_length == 0;
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
const lxb_char_t *
|
1214
|
+
lxb_dom_element_qualified_name(lxb_dom_element_t *element, size_t *len)
|
1215
|
+
{
|
1216
|
+
const lxb_tag_data_t *data;
|
1217
|
+
|
1218
|
+
if (element->qualified_name != 0) {
|
1219
|
+
data = lxb_tag_data_by_id(element->node.owner_document->tags,
|
1220
|
+
element->qualified_name);
|
1221
|
+
}
|
1222
|
+
else {
|
1223
|
+
data = lxb_tag_data_by_id(element->node.owner_document->tags,
|
1224
|
+
element->node.local_name);
|
1225
|
+
}
|
1226
|
+
|
1227
|
+
if (len != NULL) {
|
1228
|
+
*len = data->entry.length;
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
return lexbor_hash_entry_str(&data->entry);
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
const lxb_char_t *
|
1235
|
+
lxb_dom_element_qualified_name_upper(lxb_dom_element_t *element, size_t *len)
|
1236
|
+
{
|
1237
|
+
lxb_tag_data_t *data;
|
1238
|
+
|
1239
|
+
if (element->upper_name == LXB_TAG__UNDEF) {
|
1240
|
+
return lxb_dom_element_upper_update(element, len);
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
data = (lxb_tag_data_t *) element->upper_name;
|
1244
|
+
|
1245
|
+
if (len != NULL) {
|
1246
|
+
*len = data->entry.length;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
return lexbor_hash_entry_str(&data->entry);
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
static const lxb_char_t *
|
1253
|
+
lxb_dom_element_upper_update(lxb_dom_element_t *element, size_t *len)
|
1254
|
+
{
|
1255
|
+
size_t length;
|
1256
|
+
lxb_tag_data_t *data;
|
1257
|
+
const lxb_char_t *name;
|
1258
|
+
|
1259
|
+
if (element->upper_name != LXB_TAG__UNDEF) {
|
1260
|
+
/* TODO: release current tag data if ref_count == 0. */
|
1261
|
+
/* data = (lxb_tag_data_t *) element->upper_name; */
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
name = lxb_dom_element_qualified_name(element, &length);
|
1265
|
+
if (name == NULL) {
|
1266
|
+
return NULL;
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
data = lexbor_hash_insert(element->node.owner_document->tags,
|
1270
|
+
lexbor_hash_insert_upper, name, length);
|
1271
|
+
if (data == NULL) {
|
1272
|
+
return NULL;
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
data->tag_id = element->node.local_name;
|
1276
|
+
|
1277
|
+
if (len != NULL) {
|
1278
|
+
*len = length;
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
element->upper_name = (lxb_tag_id_t) data;
|
1282
|
+
|
1283
|
+
return lexbor_hash_entry_str(&data->entry);
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
const lxb_char_t *
|
1287
|
+
lxb_dom_element_local_name(lxb_dom_element_t *element, size_t *len)
|
1288
|
+
{
|
1289
|
+
const lxb_tag_data_t *data;
|
1290
|
+
|
1291
|
+
data = lxb_tag_data_by_id(element->node.owner_document->tags,
|
1292
|
+
element->node.local_name);
|
1293
|
+
if (data == NULL) {
|
1294
|
+
if (len != NULL) {
|
1295
|
+
*len = 0;
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
return NULL;
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
if (len != NULL) {
|
1302
|
+
*len = data->entry.length;
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
return lexbor_hash_entry_str(&data->entry);
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
const lxb_char_t *
|
1309
|
+
lxb_dom_element_prefix(lxb_dom_element_t *element, size_t *len)
|
1310
|
+
{
|
1311
|
+
const lxb_ns_prefix_data_t *data;
|
1312
|
+
|
1313
|
+
if (element->node.prefix == LXB_NS__UNDEF) {
|
1314
|
+
goto empty;
|
1315
|
+
}
|
1316
|
+
|
1317
|
+
data = lxb_ns_prefix_data_by_id(element->node.owner_document->tags,
|
1318
|
+
element->node.prefix);
|
1319
|
+
if (data == NULL) {
|
1320
|
+
goto empty;
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
return lexbor_hash_entry_str(&data->entry);
|
1324
|
+
|
1325
|
+
empty:
|
1326
|
+
|
1327
|
+
if (len != NULL) {
|
1328
|
+
*len = 0;
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
return NULL;
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
const lxb_char_t *
|
1335
|
+
lxb_dom_element_tag_name(lxb_dom_element_t *element, size_t *len)
|
1336
|
+
{
|
1337
|
+
lxb_dom_document_t *doc = lxb_dom_interface_node(element)->owner_document;
|
1338
|
+
|
1339
|
+
if (element->node.ns != LXB_NS_HTML
|
1340
|
+
|| doc->type != LXB_DOM_DOCUMENT_DTYPE_HTML)
|
1341
|
+
{
|
1342
|
+
return lxb_dom_element_qualified_name(element, len);
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
return lxb_dom_element_qualified_name_upper(element, len);
|
1346
|
+
}
|
1347
|
+
|
1348
|
+
|
1349
|
+
|
1350
|
+
/*
|
1351
|
+
* No inline functions for ABI.
|
1352
|
+
*/
|
1353
|
+
const lxb_char_t *
|
1354
|
+
lxb_dom_element_id_noi(lxb_dom_element_t *element, size_t *len)
|
1355
|
+
{
|
1356
|
+
return lxb_dom_element_id(element, len);
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
const lxb_char_t *
|
1360
|
+
lxb_dom_element_class_noi(lxb_dom_element_t *element, size_t *len)
|
1361
|
+
{
|
1362
|
+
return lxb_dom_element_class(element, len);
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
bool
|
1366
|
+
lxb_dom_element_is_custom_noi(lxb_dom_element_t *element)
|
1367
|
+
{
|
1368
|
+
return lxb_dom_element_is_custom(element);
|
1369
|
+
}
|
1370
|
+
|
1371
|
+
bool
|
1372
|
+
lxb_dom_element_custom_is_defined_noi(lxb_dom_element_t *element)
|
1373
|
+
{
|
1374
|
+
return lxb_dom_element_custom_is_defined(element);
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
lxb_dom_attr_t *
|
1378
|
+
lxb_dom_element_first_attribute_noi(lxb_dom_element_t *element)
|
1379
|
+
{
|
1380
|
+
return lxb_dom_element_first_attribute(element);
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
lxb_dom_attr_t *
|
1384
|
+
lxb_dom_element_next_attribute_noi(lxb_dom_attr_t *attr)
|
1385
|
+
{
|
1386
|
+
return lxb_dom_element_next_attribute(attr);
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
lxb_dom_attr_t *
|
1390
|
+
lxb_dom_element_prev_attribute_noi(lxb_dom_attr_t *attr)
|
1391
|
+
{
|
1392
|
+
return lxb_dom_element_prev_attribute(attr);
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
lxb_dom_attr_t *
|
1396
|
+
lxb_dom_element_last_attribute_noi(lxb_dom_element_t *element)
|
1397
|
+
{
|
1398
|
+
return lxb_dom_element_last_attribute(element);
|
1399
|
+
}
|
1400
|
+
|
1401
|
+
lxb_dom_attr_t *
|
1402
|
+
lxb_dom_element_id_attribute_noi(lxb_dom_element_t *element)
|
1403
|
+
{
|
1404
|
+
return lxb_dom_element_id_attribute(element);
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
lxb_dom_attr_t *
|
1408
|
+
lxb_dom_element_class_attribute_noi(lxb_dom_element_t *element)
|
1409
|
+
{
|
1410
|
+
return lxb_dom_element_class_attribute(element);
|
1411
|
+
}
|