void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame) { ASSERT(frame); // WebCore::writeURL(m_writableDataObject.get(), url, title, true, false); if (!m_writableData) m_writableData = new QMimeData; CachedImage* cachedImage = getCachedImage(element); if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded()) return; QPixmap* pixmap = cachedImage->image()->nativeImageForCurrentFrame(); if (pixmap) m_writableData->setImageData(*pixmap); AtomicString imageURL = element->getAttribute(HTMLNames::srcAttr); if (imageURL.isEmpty()) return; KURL fullURL = frame->document()->completeURL(deprecatedParseURL(imageURL)); if (fullURL.isEmpty()) return; QList<QUrl> urls; urls.append(url); urls.append(fullURL); m_writableData->setText(title); m_writableData->setUrls(urls); #ifndef QT_NO_CLIPBOARD if (!isForDragging()) QApplication::clipboard()->setMimeData(m_writableData); #endif }
void Pasteboard::writeImage(Node* node, const KURL&, const String& title) { ASSERT(node); ASSERT(node->renderer()); ASSERT(node->renderer()->isImage()); RenderImage* renderer = toRenderImage(node->renderer()); CachedImage* cachedImage = renderer->cachedImage(); ASSERT(cachedImage); Image* image = cachedImage->image(); ASSERT(image); // If the image is wrapped in a link, |url| points to the target of the // link. This isn't useful to us, so get the actual image URL. AtomicString urlString; if (node->hasTagName(HTMLNames::imgTag) || node->hasTagName(HTMLNames::inputTag)) urlString = static_cast<Element*>(node)->getAttribute(HTMLNames::srcAttr); #if ENABLE(SVG) else if (node->hasTagName(SVGNames::imageTag)) urlString = static_cast<Element*>(node)->getAttribute(XLinkNames::hrefAttr); #endif else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) { Element* element = static_cast<Element*>(node); urlString = element->getAttribute(element->imageSourceAttributeName()); } KURL url = urlString.isEmpty() ? KURL() : node->document()->completeURL(deprecatedParseURL(urlString)); NativeImageSkia* bitmap = 0; #if !PLATFORM(CG) bitmap = image->nativeImageForCurrentFrame(); #endif ChromiumBridge::clipboardWriteImage(bitmap, url, title); }
void SVGAElement::defaultEventHandler(Event* evt) { if (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) { MouseEvent* e = 0; if (evt->type() == eventNames().clickEvent && evt->isMouseEvent()) e = static_cast<MouseEvent*>(evt); KeyboardEvent* k = 0; if (evt->type() == eventNames().keydownEvent && evt->isKeyboardEvent()) k = static_cast<KeyboardEvent*>(evt); if (e && e->button() == RightButton) { SVGStyledTransformableElement::defaultEventHandler(evt); return; } if (k) { if (k->keyIdentifier() != "Enter") { SVGStyledTransformableElement::defaultEventHandler(evt); return; } evt->setDefaultHandled(); dispatchSimulatedClick(evt); return; } String target = this->target(); if (e && e->button() == MiddleButton) target = "_blank"; else if (target.isEmpty()) // if target is empty, default to "_self" or use xlink:target if set target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self"; if (!evt->defaultPrevented()) { String url = deprecatedParseURL(href()); #if ENABLE(SVG_ANIMATION) if (url.startsWith("#")) { Element* targetElement = document()->getElementById(url.substring(1)); if (SVGSMILElement::isSMILElement(targetElement)) { SVGSMILElement* timed = static_cast<SVGSMILElement*>(targetElement); timed->beginByLinkActivation(); evt->setDefaultHandled(); SVGStyledTransformableElement::defaultEventHandler(evt); return; } } #endif if (document()->frame()) document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, false, true, SendReferrer); } evt->setDefaultHandled(); } SVGStyledTransformableElement::defaultEventHandler(evt); }
void CSSPreloadScanner::emitRule() { String rule(m_rule.data(), m_rule.size()); if (equalIgnoringCase(rule, "import") && !m_ruleValue.isEmpty()) { String value(m_ruleValue.data(), m_ruleValue.size()); String url = deprecatedParseURL(value); if (!url.isEmpty()) m_document->cachedResourceLoader()->preload(CachedResource::CSSStyleSheet, url, String(), m_scanningBody); } m_rule.clear(); m_ruleValue.clear(); }
void HTMLObjectElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == typeAttr) { m_serviceType = attr->value().lower(); size_t pos = m_serviceType.find(";"); if (pos != notFound) m_serviceType = m_serviceType.left(pos); if (renderer()) setNeedsWidgetUpdate(true); if (!isImageType() && m_imageLoader) m_imageLoader.clear(); } else if (attr->name() == dataAttr) { m_url = deprecatedParseURL(attr->value()); if (renderer()) { setNeedsWidgetUpdate(true); if (isImageType()) { if (!m_imageLoader) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); m_imageLoader->updateFromElementIgnoringPreviousError(); } } } else if (attr->name() == classidAttr) { m_classId = attr->value(); if (renderer()) setNeedsWidgetUpdate(true); } else if (attr->name() == onloadAttr) setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr)); else if (attr->name() == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr)); else if (attr->name() == nameAttr) { const AtomicString& newName = attr->value(); if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeNamedItem(m_name); document->addNamedItem(newName); } m_name = newName; } else if (isIdAttributeName(attr->name())) { const AtomicString& newId = attr->value(); if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_id); document->addExtraNamedItem(newId); } m_id = newId; // also call superclass HTMLPlugInImageElement::parseMappedAttribute(attr); } else HTMLPlugInImageElement::parseMappedAttribute(attr); }
void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr) { if (attr->name() == relAttr) { tokenizeRelAttribute(attr->value(), m_isStyleSheet, m_alternate, m_isIcon, m_isDNSPrefetch); process(); } else if (attr->name() == hrefAttr) { m_url = document()->completeURL(deprecatedParseURL(attr->value())); process(); } else if (attr->name() == typeAttr) { m_type = attr->value(); process(); } else if (attr->name() == mediaAttr) { m_media = attr->value().string().lower(); process(); } else if (attr->name() == disabledAttr) { setDisabledState(!attr->isNull()); } else if (attr->name() == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr)); else { if (attr->name() == titleAttr && m_sheet) m_sheet->setTitle(attr->value()); HTMLElement::parseMappedAttribute(attr); } }
// FIXME: This function should not deal with url or serviceType! void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType) { HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames; String urlParameter; // Scan the PARAM children and store their name/value pairs. // Get the URL and type from the params if we don't already have them. for (Node* child = firstChild(); child; child = child->nextSibling()) { if (!child->hasTagName(paramTag)) continue; HTMLParamElement* p = static_cast<HTMLParamElement*>(child); String name = p->name(); if (name.isEmpty()) continue; uniqueParamNames.add(name.impl()); paramNames.append(p->name()); paramValues.append(p->value()); // FIXME: url adjustment does not belong in this function. if (url.isEmpty() && urlParameter.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url"))) urlParameter = deprecatedParseURL(p->value()); // FIXME: serviceType calculation does not belong in this function. if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) { serviceType = p->value(); size_t pos = serviceType.find(";"); if (pos != notFound) serviceType = serviceType.left(pos); } } // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM, // else our Java plugin will misinterpret it. [4004531] String codebase; if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) { codebase = "codebase"; uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already } // Turn the attributes of the <object> element into arrays, but don't override <param> values. NamedNodeMap* attributes = this->attributes(true); if (attributes) { for (unsigned i = 0; i < attributes->length(); ++i) { Attribute* it = attributes->attributeItem(i); const AtomicString& name = it->name().localName(); if (!uniqueParamNames.contains(name.impl())) { paramNames.append(name.string()); paramValues.append(it->value().string()); } } } mapDataParamToSrc(¶mNames, ¶mValues); // HTML5 says that an object resource's URL is specified by the object's data // attribute, not by a param element. However, for compatibility, allow the // resource's URL to be given by a param named "src", "movie", "code" or "url" // if we know that resource points to a plug-in. if (url.isEmpty() && !urlParameter.isEmpty()) { SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); if (loader->resourceWillUsePlugin(urlParameter, serviceType)) url = urlParameter; } }
String HTMLImageLoader::sourceURI(const AtomicString& attr) const { return deprecatedParseURL(attr); }