Copied from lib\RmlUi\Source\Core\Elements\ElementLabel.cpp Get the first descending element whose tag name matches one of tags.
| 34 | //! Copied from lib\RmlUi\Source\Core\Elements\ElementLabel.cpp |
| 35 | // Get the first descending element whose tag name matches one of tags. |
| 36 | static Rml::Element* TagMatchRecursive(const Rml::StringList& tags, Rml::Element* element) |
| 37 | { |
| 38 | const int num_children = element->GetNumChildren(); |
| 39 | |
| 40 | for (int i = 0; i < num_children; i++) |
| 41 | { |
| 42 | Rml::Element* child = element->GetChild(i); |
| 43 | |
| 44 | for (const Rml::String& tag : tags) |
| 45 | { |
| 46 | if (child->GetTagName() == tag) |
| 47 | return child; |
| 48 | } |
| 49 | |
| 50 | Rml::Element* matching_element = TagMatchRecursive(tags, child); |
| 51 | if (matching_element) |
| 52 | return matching_element; |
| 53 | } |
| 54 | |
| 55 | return nullptr; |
| 56 | } |
| 57 | |
| 58 | Rml::Element* get_target(Rml::ElementDocument* document, Rml::Element* element) { |
| 59 | // Labels can have targets, so check if this element is a label. |