4820// instead of using the cached list, get the current list because
4821// we expect some JS to have removed some elements
4822void Document::recalculateIconURLs()
4823{
4824 static const char* const iconMIMEType = "image/x-icon";
4825
4826 // Clear the list of iconURLs. This is the only way to get rid of old urls in the list.
4827 m_iconURLs.clear();
4828
4829 // Walk the children of the head looking for type = link, rel = "shortcut icon".
4830 HTMLCollection* children = head()->children();
4831 for (Node* child = children->firstItem(); child; child = children->nextItem()) {
4832 if (!child->hasTagName(linkTag))
4833 continue;
4834 HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(child);
4835 if (!equalIgnoringCase(linkElement->type(), iconMIMEType)
4836 || !(linkElement->iconType() == Favicon))
4837 continue;
4838 if (linkElement->href().isEmpty())
4839 continue;
4840
4841 // Add the URL to our list. We put it at the front to ensure that icons seen later
4842 // take precedence as required by the spec.
4843 IconURL newURL(KURL(ParsedURLString, linkElement->href().string().ascii().data()),
4844 linkElement->iconSizes().ascii().data(),
4845 linkElement->type().ascii().data(),
4846 linkElement->iconType());
4847 m_iconURLs.prepend(newURL);
4848 }
4849
4850 return;
4851}
4852