DOMTokenListImp::DOMTokenListImp(const ElementPtr& element, const std::u16string& localName) : element(element), localName(localName) { if (!element) return; std::u16string value = element->getAttribute(localName); boost::algorithm::split(tokens, value, isSpace); }
HTMLFormControlsCollectionImp::HTMLFormControlsCollectionImp(const HTMLFormElementPtr& form) : length(0) { ElementPtr i = form; while (i = i->getNextElement(form)) { if (isListedElement(i)) { std::u16string name; Nullable<std::u16string> a = i->getAttribute(u"name"); if (a.hasValue()) name = a.value(); if (name.empty()) { a = i->getAttribute(u"id"); if (a.hasValue()) name = a.value(); } Object found = namedItem(name); if (!found) { map.insert(std::pair<const std::u16string, Object>(name, i)); ++length; continue; } if (html::RadioNodeList::hasInstance(found)) { html::RadioNodeList r = interface_cast<html::RadioNodeList>(found); if (auto list = std::dynamic_pointer_cast<RadioNodeListImp>(r.self())) { list->addItem(i); ++length; } continue; } auto list = std::make_shared<RadioNodeListImp>(); if (list) { list->addItem(interface_cast<Element>(found)); list->addItem(i); ++length; map.erase(name); map.insert(std::pair<const std::u16string, Object>(name, list)); } } } }