本文整理汇总了C++中HTMLImageElement类的典型用法代码示例。如果您正苦于以下问题:C++ HTMLImageElement类的具体用法?C++ HTMLImageElement怎么用?C++ HTMLImageElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTMLImageElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendServerMapMousePosition
static void appendServerMapMousePosition(String& url, Event* event)
{
if (!event->isMouseEvent())
return;
ASSERT(event->target());
Node* target = event->target()->toNode();
ASSERT(target);
if (!target->hasTagName(imgTag))
return;
HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(event->target()->toNode());
if (!imageElement || !imageElement->isServerMap())
return;
RenderImage* renderer = toRenderImage(imageElement->renderer());
if (!renderer)
return;
// FIXME: This should probably pass true for useTransforms.
FloatPoint absolutePosition = renderer->absoluteToLocal(FloatPoint(static_cast<MouseEvent*>(event)->pageX(), static_cast<MouseEvent*>(event)->pageY()));
int x = absolutePosition.x();
int y = absolutePosition.y();
url += "?";
url += String::number(x);
url += ",";
url += String::number(y);
}
示例2: toHTMLElement
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;
}
示例3: toHTMLImageElement
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;
}
示例4: urlForBlankFrame
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);
}
示例5: elementForTapHighlight
// This method filters what element will get tap-highlight'ed or not. To start with,
// we are going to highlight links (anchors with a valid href element), and elements
// whose tap highlight color value is different than the default value.
static Element* elementForTapHighlight(Element* elementUnderFatFinger)
{
// Do not bail out right way here if there element does not have a renderer.
// It is the casefor <map> (descendent of <area>) elements. The associated <image>
// element actually has the renderer.
if (elementUnderFatFinger->renderer()) {
Color tapHighlightColor = elementUnderFatFinger->renderStyle()->tapHighlightColor();
if (tapHighlightColor != RenderTheme::defaultTheme()->platformTapHighlightColor())
return elementUnderFatFinger;
}
bool isArea = elementUnderFatFinger->hasTagName(HTMLNames::areaTag);
Node* linkNode = elementUnderFatFinger->enclosingLinkEventParentOrSelf();
if (!linkNode || !linkNode->isHTMLElement() || (!linkNode->renderer() && !isArea))
return 0;
ASSERT(linkNode->isLink());
// FatFingers class selector ensure only anchor with valid href attr value get here.
// It includes empty hrefs.
Element* highlightCandidateElement = static_cast<Element*>(linkNode);
if (!isArea)
return highlightCandidateElement;
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(highlightCandidateElement);
HTMLImageElement* image = area->imageElement();
if (image && image->renderer())
return image;
return 0;
}
示例6: appendServerMapMousePosition
static void appendServerMapMousePosition(StringBuilder& url, Event* event)
{
if (!event->isMouseEvent())
return;
ASSERT(event->target());
Node* target = event->target()->toNode();
ASSERT(target);
if (!isHTMLImageElement(target))
return;
HTMLImageElement* imageElement = toHTMLImageElement(target);
if (!imageElement || !imageElement->isServerMap())
return;
if (!imageElement->renderer() || !imageElement->renderer()->isRenderImage())
return;
RenderImage* renderer = toRenderImage(imageElement->renderer());
// FIXME: This should probably pass true for useTransforms.
FloatPoint absolutePosition = renderer->absoluteToLocal(FloatPoint(toMouseEvent(event)->pageX(), toMouseEvent(event)->pageY()));
int x = absolutePosition.x();
int y = absolutePosition.y();
url.append('?');
url.appendNumber(x);
url.append(',');
url.appendNumber(y);
}
示例7: isMapAttrGetter
static v8::Handle<v8::Value> isMapAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLImageElement.isMap._get");
HTMLImageElement* imp = V8HTMLImageElement::toNative(info.Holder());
if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::ismapAttr));
}
示例8: vspaceAttrGetter
static v8::Handle<v8::Value> vspaceAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLImageElement.vspace._get");
HTMLImageElement* imp = V8HTMLImageElement::toNative(info.Holder());
if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::vspaceAttr));
}
示例9: autoPushRoot
void RenderImage::readyWRATHWidgetIntoRect(PaintedWidgetsOfWRATHHandle& handle,
ContextOfWRATH *wrath_context, const IntRect& rect)
{
RenderImage_ReadyWRATHWidgetIntoRect *d(RenderImage_ReadyWRATHWidgetIntoRect::object(this, handle));
ContextOfWRATH::AutoPushNode autoPushRoot(wrath_context, d->m_root_node);
d->m_image.visible(false);
if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || rect.width() <= 0 || rect.height() <= 0) {
return;
}
RefPtr<Image> img = m_imageResource->image(rect.width(), rect.height());
if (!img || img->isNull()) {
return;
}
HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? static_cast<HTMLImageElement*>(node()) : 0;
CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
Image* image = m_imageResource->image().get();
/*
bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, rect.size());
[WRATH-TODO]: What to do with the above function call?
*/
/*
context->drawImage(m_imageResource->image(rect.width(), rect.height()).get(), style()->colorSpace(), rect, compositeOperator, useLowQualityScaling);
*/
d->m_image.visible(true);
WRATH_drawImage(d->m_image, wrath_context,
m_imageResource->image(rect.width(), rect.height()).get(), style()->colorSpace(), rect, compositeOperator, false /*useLowQualityScaling*/);
}
示例10: lowsrcAttrGetter
static v8::Handle<v8::Value> lowsrcAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLImageElement.lowsrc._get");
HTMLImageElement* imp = V8HTMLImageElement::toNative(info.Holder());
if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
return v8String(imp->getURLAttribute(WebCore::HTMLNames::lowsrcAttr));
}
示例11: completeAttrGetter
static v8::Handle<v8::Value> completeAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLImageElement.complete._get");
HTMLImageElement* imp = V8HTMLImageElement::toNative(info.Holder());
if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
return v8Boolean(imp->complete());
}
示例12: getNamedFormItem
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;
}
示例13: NS_ENSURE_SUCCESS
nsresult
HTMLSourceElement::BindToTree(nsIDocument *aDocument,
nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument,
aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aParent && aParent->IsNodeOfType(nsINode::eMEDIA)) {
HTMLMediaElement* media = static_cast<HTMLMediaElement*>(aParent);
media->NotifyAddedSource();
} else if (aParent && aParent->IsHTMLElement(nsGkAtoms::picture)) {
// Find any img siblings after this <source> and notify them
nsCOMPtr<nsIContent> sibling = AsContent();
while ( (sibling = sibling->GetNextSibling()) ) {
if (sibling->IsHTMLElement(nsGkAtoms::img)) {
HTMLImageElement *img = static_cast<HTMLImageElement*>(sibling.get());
img->PictureSourceAdded(AsContent());
}
}
}
return NS_OK;
}
示例14: visibleNode
FocusCandidate::FocusCandidate(Node* node, FocusDirection direction)
: visibleNode(0)
, focusableNode(0)
, enclosingScrollableBox(0)
, distance(maxDistance())
, parentDistance(maxDistance())
, alignment(None)
, parentAlignment(None)
, isOffscreen(true)
, isOffscreenAfterScrolling(true)
{
ASSERT(node);
ASSERT(node->isElementNode());
if (node->hasTagName(HTMLNames::areaTag)) {
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
HTMLImageElement* image = area->imageElement();
if (!image || !image->renderer())
return;
visibleNode = image;
rect = virtualRectForAreaElementAndDirection(area, direction);
} else {
if (!node->renderer())
return;
visibleNode = node;
rect = nodeRectInAbsoluteCoordinates(node, true /* ignore border */);
}
focusableNode = node;
isOffscreen = hasOffscreenRect(visibleNode);
isOffscreenAfterScrolling = hasOffscreenRect(visibleNode, direction);
}
示例15: heightAttrGetter
static v8::Handle<v8::Value> heightAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLImageElement.height._get");
HTMLImageElement* imp = V8HTMLImageElement::toNative(info.Holder());
if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
return v8::Integer::New(imp->height());
}