Node* HTMLCollection::nextNamedItem(const AtomicString& name) const { resetCollectionInfo(); m_info->checkConsistency(); for (Element* e = itemAfter(m_info->current); e; e = itemAfter(e)) { if (checkForNameMatch(e, m_idsDone, name)) { m_info->current = e; return e; } } if (m_idsDone) { m_info->current = 0; return 0; } m_idsDone = true; for (Element* e = itemAfter(m_info->current); e; e = itemAfter(e)) { if (checkForNameMatch(e, m_idsDone, name)) { m_info->current = e; return e; } } return 0; }
Node* HTMLCollection::namedItem(const AtomicString& name) const { // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp // This method first searches for an object with a matching id // attribute. If a match is not found, the method then searches for an // object with a matching name attribute, but only on those elements // that are allowed a name attribute. resetCollectionInfo(); m_idsDone = false; for (Element* e = itemAfter(0); e; e = itemAfter(e)) { if (checkForNameMatch(e, m_idsDone, name)) { m_info->current = e; return e; } } m_idsDone = true; for (Element* e = itemAfter(0); e; e = itemAfter(e)) { if (checkForNameMatch(e, m_idsDone, name)) { m_info->current = e; return e; } } m_info->current = 0; return 0; }
unsigned HTMLCollection::calcLength() const { unsigned len = 0; for (Element* current = itemAfter(0); current; current = itemAfter(current)) ++len; return len; }
void PlaylistWindow::activateNext() { auto qdp = currentPlaylistWidget(); auto now = qdp->nowPlayingItem(); auto pl = PlaylistCollection::getSingleton()->playlistOf(qdp->uuid()); auto next = pl->itemAfter(now); if (!!next) activateItem(qdp->uuid(), next->uuid()); }
Node* HTMLCollection::nextItem() const { resetCollectionInfo(); // Look for the 'second' item. The first one is currentItem, already given back. Element* retval = itemAfter(m_info->current); m_info->current = retval; m_info->position++; return retval; }
Node* HTMLCollection::item(unsigned index) const { resetCollectionInfo(); if (m_info->current && m_info->position == index) return m_info->current; if (m_info->hasLength && m_info->length <= index) return 0; if (!m_info->current || m_info->position > index) { m_info->current = itemAfter(0); m_info->position = 0; if (!m_info->current) return 0; } Element* e = m_info->current; for (unsigned pos = m_info->position; e && pos < index; pos++) e = itemAfter(e); m_info->current = e; m_info->position = index; return m_info->current; }
QUuid PlaylistWindow::getItemAfter(QUuid list, QUuid item) { auto pl = PlaylistCollection::getSingleton()->playlistOf(list); if (!pl) return QUuid(); QUuid uuid = pl->queueTakeFirst(); if (!uuid.isNull()) return uuid; QSharedPointer<Item> after = pl->itemAfter(item); if (!after) return QUuid(); return after->uuid(); }
void HTMLCollection::updateNameCache() const { if (m_info->hasNameCache) return; for (Element* element = itemAfter(0); element; element = itemAfter(element)) { if (!element->isHTMLElement()) continue; HTMLElement* e = toHTMLElement(element); const AtomicString& idAttrVal = e->getIdAttribute(); const AtomicString& nameAttrVal = e->getAttribute(nameAttr); if (!idAttrVal.isEmpty()) { // add to id cache Vector<Element*>* idVector = m_info->idCache.get(idAttrVal.impl()); if (!idVector) { idVector = new Vector<Element*>; m_info->idCache.add(idAttrVal.impl(), idVector); } idVector->append(e); } if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && (m_type != DocAll || (e->hasLocalName(imgTag) || e->hasLocalName(formTag) || e->hasLocalName(appletTag) || e->hasLocalName(objectTag) || e->hasLocalName(embedTag) || e->hasLocalName(inputTag) || e->hasLocalName(selectTag)))) { // add to name cache Vector<Element*>* nameVector = m_info->nameCache.get(nameAttrVal.impl()); if (!nameVector) { nameVector = new Vector<Element*>; m_info->nameCache.add(nameAttrVal.impl(), nameVector); } nameVector->append(e); } } m_info->hasNameCache = true; }