Element* HTMLFormCollection::getNamedFormItem(const QualifiedName& attrName, const String& name, int duplicateNumber) const { HTMLFormElement* form = static_cast<HTMLFormElement*>(base()); bool foundInputElements = false; for (unsigned i = 0; i < form->formElements.size(); ++i) { HTMLFormControlElement* e = form->formElements[i]; const QualifiedName& attributeName = (attrName == idAttr) ? e->idAttributeName() : attrName; if (e->isEnumeratable() && e->getAttribute(attributeName) == name) { foundInputElements = true; if (!duplicateNumber) return e; --duplicateNumber; } } if (!foundInputElements) { for (unsigned i = 0; i < form->imgElements.size(); ++i) { HTMLImageElement* e = form->imgElements[i]; const QualifiedName& attributeName = (attrName == idAttr) ? e->idAttributeName() : attrName; if (e->getAttribute(attributeName) == name) { if (!duplicateNumber) return e; --duplicateNumber; } } } return 0; }
Element* HTMLFormCollection::getNamedFormItem(const QualifiedName& attrName, const String& name, int duplicateNumber) const { HTMLFormElement* form = static_cast<HTMLFormElement*>(base()); bool foundInputElements = false; for (unsigned i = 0; i < form->m_associatedElements.size(); ++i) { FormAssociatedElement* associatedElement = form->m_associatedElements[i]; HTMLElement* element = toHTMLElement(associatedElement); if (associatedElement->isEnumeratable() && element->getAttribute(attrName) == name) { foundInputElements = true; if (!duplicateNumber) return element; --duplicateNumber; } } if (!foundInputElements) { for (unsigned i = 0; i < form->m_imageElements.size(); ++i) { HTMLImageElement* element = form->m_imageElements[i]; if (element->getAttribute(attrName) == name) { if (!duplicateNumber) return element; --duplicateNumber; } } } return 0; }
const AtomicString& HitTestResult::altDisplayString() const { if (!m_innerNonSharedNode) return nullAtom; if (m_innerNonSharedNode->hasTagName(imgTag)) { HTMLImageElement* image = toHTMLImageElement(m_innerNonSharedNode); return image->getAttribute(altAttr); } if (m_innerNonSharedNode->hasTagName(inputTag)) { HTMLInputElement* input = toHTMLInputElement(m_innerNonSharedNode); return input->alt(); } #if ENABLE(WML) if (m_innerNonSharedNode->hasTagName(WMLNames::imgTag)) { WMLImageElement* image = toWMLImageElement(m_innerNonSharedNode); // FIXME return image->fastGetAttribute(altAttr);//image->altText(); } #endif return nullAtom; }
void PageSerializer::serializeFrame(Frame* frame) { Document* document = frame->document(); URL url = document->url(); if (!url.isValid() || url.isBlankURL()) { // For blank frames we generate a fake URL so they can be referenced by their containing frame. url = urlForBlankFrame(frame); } if (m_resourceURLs.contains(url)) { // FIXME: We could have 2 frame with the same URL but which were dynamically changed and have now // different content. So we should serialize both and somehow rename the frame src in the containing // frame. Arg! return; } Vector<Node*> nodes; SerializerMarkupAccumulator accumulator(*this, *document, &nodes); TextEncoding textEncoding(document->charset()); CString data; if (!textEncoding.isValid()) { // FIXME: iframes used as images trigger this. We should deal with them correctly. return; } String text = accumulator.serializeNodes(*document->documentElement(), 0, IncludeNode); CString frameHTML = textEncoding.encode(text, EntitiesForUnencodables); m_resources->append(Resource(url, document->suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length()))); m_resourceURLs.add(url); for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++iter) { Node* node = *iter; if (!node->isElementNode()) continue; Element* element = toElement(node); // We have to process in-line style as it might contain some resources (typically background images). if (element->isStyledElement()) retrieveResourcesForProperties(toStyledElement(element)->inlineStyle(), document); if (isHTMLImageElement(element)) { HTMLImageElement* imageElement = toHTMLImageElement(element); URL url = document->completeURL(imageElement->getAttribute(HTMLNames::srcAttr)); CachedImage* cachedImage = imageElement->cachedImage(); addImageToResources(cachedImage, imageElement->renderer(), url); } else if (element->hasTagName(HTMLNames::linkTag)) { HTMLLinkElement* linkElement = toHTMLLinkElement(element); if (CSSStyleSheet* sheet = linkElement->sheet()) { URL url = document->completeURL(linkElement->getAttribute(HTMLNames::hrefAttr)); serializeCSSStyleSheet(sheet, url); ASSERT(m_resourceURLs.contains(url)); } } else if (isHTMLStyleElement(element)) { if (CSSStyleSheet* sheet = toHTMLStyleElement(element)->sheet()) serializeCSSStyleSheet(sheet, URL()); } } for (Frame* childFrame = frame->tree().firstChild(); childFrame; childFrame = childFrame->tree().nextSibling()) serializeFrame(childFrame); }
Node* HTMLFormCollection::getNamedFormItem(const QualifiedName& attrName, const String& name, int duplicateNumber, bool caseSensitive) const { if (m_base->isElementNode()) { HTMLElement* baseElement = static_cast<HTMLElement*>(m_base.get()); bool foundInputElements = false; if (baseElement->hasLocalName(formTag)) { HTMLFormElement* f = static_cast<HTMLFormElement*>(baseElement); for (unsigned i = 0; i < f->formElements.size(); ++i) { HTMLGenericFormElement* e = f->formElements[i]; if (e->isEnumeratable()) { bool found; if (caseSensitive) found = e->getAttribute(attrName) == name; else found = e->getAttribute(attrName).domString().lower() == name.lower(); if (found) { foundInputElements = true; if (!duplicateNumber) return e; --duplicateNumber; } } } } if (!foundInputElements) { HTMLFormElement* f = static_cast<HTMLFormElement*>(baseElement); for(unsigned i = 0; i < f->imgElements.size(); ++i) { HTMLImageElement* e = f->imgElements[i]; bool found; if (caseSensitive) found = e->getAttribute(attrName) == name; else found = e->getAttribute(attrName).domString().lower() == name.lower(); if (found) { if (!duplicateNumber) return e; --duplicateNumber; } } } } return 0; }
Element* HTMLFormCollection::getNamedFormItem(const QualifiedName& attrName, const String& name, int duplicateNumber, bool caseSensitive) const { HTMLFormElement* form = static_cast<HTMLFormElement*>(base()); bool foundInputElements = false; for (unsigned i = 0; i < form->formElements.size(); ++i) { HTMLFormControlElement* e = form->formElements[i]; if (e->isEnumeratable()) { bool found; if (caseSensitive) found = e->getAttribute(attrName) == name; else found = equalIgnoringCase(e->getAttribute(attrName), name); if (found) { foundInputElements = true; if (!duplicateNumber) return e; --duplicateNumber; } } } if (!foundInputElements) { for (unsigned i = 0; i < form->imgElements.size(); ++i) { HTMLImageElement* e = form->imgElements[i]; bool found; if (caseSensitive) found = e->getAttribute(attrName) == name; else found = equalIgnoringCase(e->getAttribute(attrName), name); if (found) { if (!duplicateNumber) return e; --duplicateNumber; } } } return 0; }
HTMLImageElement* HTMLMapElement::imageElement() const { RefPtr<HTMLCollection> coll = document()->images(); for (Node* curr = coll->firstItem(); curr; curr = coll->nextItem()) { if (!curr->hasTagName(imgTag)) continue; // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning, // which has to be stripped off. HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(curr); String useMapName = imageElement->getAttribute(usemapAttr).string().substring(1); if (equalIgnoringCase(useMapName, m_name)) return imageElement; } return 0; }
String HitTestResult::altDisplayString() const { if (!m_innerNonSharedNode) return String(); if (m_innerNonSharedNode->hasTagName(imgTag)) { HTMLImageElement* image = static_cast<HTMLImageElement*>(m_innerNonSharedNode.get()); return displayString(image->getAttribute(altAttr), m_innerNonSharedNode.get()); } if (m_innerNonSharedNode->hasTagName(inputTag)) { HTMLInputElement* input = static_cast<HTMLInputElement*>(m_innerNonSharedNode.get()); return displayString(input->alt(), m_innerNonSharedNode.get()); } return String(); }
String HitTestResult::altDisplayString() const { if (!m_innerNonSharedNode) return String(); if (isHTMLImageElement(m_innerNonSharedNode.get())) { HTMLImageElement* image = toHTMLImageElement(m_innerNonSharedNode.get()); return displayString(image->getAttribute(altAttr), m_innerNonSharedNode.get()); } if (isHTMLInputElement(m_innerNonSharedNode.get())) { HTMLInputElement* input = toHTMLInputElement(m_innerNonSharedNode.get()); return displayString(input->alt(), m_innerNonSharedNode.get()); } return String(); }
HTMLImageElement* HTMLMapElement::imageElement() { HTMLCollection* images = document()->images(); for (unsigned i = 0; Node* curr = images->item(i); i++) { if (!curr->hasTagName(imgTag)) continue; // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning, // which has to be stripped off. HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(curr); String useMapName = imageElement->getAttribute(usemapAttr).string().substring(1); if (equalIgnoringCase(useMapName, m_name)) return imageElement; } return 0; }
void HTMLFormCollection::updateNameCache() const { if (m_cache.hasNameCache) return; HashSet<AtomicStringImpl*> foundInputElements; HTMLFormElement* f = static_cast<HTMLFormElement*>(base()); for (unsigned i = 0; i < f->m_associatedElements.size(); ++i) { FormAssociatedElement* associatedElement = f->m_associatedElements[i]; if (associatedElement->isEnumeratable()) { HTMLElement* element = toHTMLElement(associatedElement); const AtomicString& idAttrVal = element->getIdAttribute(); const AtomicString& nameAttrVal = element->getAttribute(nameAttr); if (!idAttrVal.isEmpty()) { append(m_cache.idCache, idAttrVal, element); foundInputElements.add(idAttrVal.impl()); } if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { append(m_cache.nameCache, nameAttrVal, element); foundInputElements.add(nameAttrVal.impl()); } } } for (unsigned i = 0; i < f->m_imageElements.size(); ++i) { HTMLImageElement* element = f->m_imageElements[i]; const AtomicString& idAttrVal = element->getIdAttribute(); const AtomicString& nameAttrVal = element->getAttribute(nameAttr); if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.impl())) append(m_cache.idCache, idAttrVal, element); if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInputElements.contains(nameAttrVal.impl())) append(m_cache.nameCache, nameAttrVal, element); } m_cache.hasNameCache = true; }
void HTMLFormCollection::updateNameCache() const { if (info()->hasNameCache) return; HashSet<AtomicStringImpl*> foundInputElements; HTMLFormElement* f = static_cast<HTMLFormElement*>(base()); for (unsigned i = 0; i < f->formElements.size(); ++i) { HTMLFormControlElement* e = f->formElements[i]; if (e->isEnumeratable()) { const AtomicString& idAttrVal = e->getAttribute(e->idAttributeName()); const AtomicString& nameAttrVal = e->getAttribute(nameAttr); if (!idAttrVal.isEmpty()) { // add to id cache Vector<Element*>* idVector = info()->idCache.get(idAttrVal.impl()); if (!idVector) { idVector = new Vector<Element*>; info()->idCache.add(idAttrVal.impl(), idVector); } idVector->append(e); foundInputElements.add(idAttrVal.impl()); } if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { // add to name cache Vector<Element*>* nameVector = info()->nameCache.get(nameAttrVal.impl()); if (!nameVector) { nameVector = new Vector<Element*>; info()->nameCache.add(nameAttrVal.impl(), nameVector); } nameVector->append(e); foundInputElements.add(nameAttrVal.impl()); } } } for (unsigned i = 0; i < f->imgElements.size(); ++i) { HTMLImageElement* e = f->imgElements[i]; const AtomicString& idAttrVal = e->getAttribute(e->idAttributeName()); const AtomicString& nameAttrVal = e->getAttribute(nameAttr); if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.impl())) { // add to id cache Vector<Element*>* idVector = info()->idCache.get(idAttrVal.impl()); if (!idVector) { idVector = new Vector<Element*>; info()->idCache.add(idAttrVal.impl(), idVector); } idVector->append(e); } if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInputElements.contains(nameAttrVal.impl())) { // add to name cache Vector<Element*>* nameVector = info()->nameCache.get(nameAttrVal.impl()); if (!nameVector) { nameVector = new Vector<Element*>; info()->nameCache.add(nameAttrVal.impl(), nameVector); } nameVector->append(e); } } info()->hasNameCache = true; }
HTMLMapElement* RenderImage::imageMap() const { HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(node()) : 0; return i ? i->document()->getImageMap(i->getAttribute(usemapAttr)) : 0; }