本文整理汇总了C++中CachedImage::url方法的典型用法代码示例。如果您正苦于以下问题:C++ CachedImage::url方法的具体用法?C++ CachedImage::url怎么用?C++ CachedImage::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CachedImage
的用法示例。
在下文中一共展示了CachedImage::url方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieveResourcesForCSSDeclaration
void PageSerializer::retrieveResourcesForCSSDeclaration(StylePropertySet* styleDeclaration, Document* document)
{
if (!styleDeclaration)
return;
// The background-image and list-style-image (for ul or ol) are the CSS properties
// that make use of images. We iterate to make sure we include any other
// image properties there might be.
unsigned propertyCount = styleDeclaration->propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) {
RefPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i).value();
if (!cssValue->isImageValue())
continue;
CSSImageValue* imageValue = static_cast<CSSImageValue*>(cssValue.get());
StyleImage* styleImage = imageValue->cachedOrPendingImage();
// Non cached-images are just place-holders and do not contain data.
if (!styleImage || !styleImage->isCachedImage())
continue;
CachedImage* image = static_cast<StyleCachedImage*>(styleImage)->cachedImage();
KURL url = document->completeURL(image->url());
addImageToResources(image, 0, url);
}
}
示例2: setAutoLoadImages
void DocLoader::setAutoLoadImages(bool enable)
{
if (enable == m_autoLoadImages)
return;
m_autoLoadImages = enable;
if (!m_autoLoadImages)
return;
DocumentResourceMap::iterator end = m_documentResources.end();
for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) {
CachedResource* resource = it->second.get();
if (resource->type() == CachedResource::ImageResource) {
CachedImage* image = const_cast<CachedImage*>(static_cast<const CachedImage*>(resource));
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
if (shouldBlockNetworkImage(image->url()))
continue;
#endif
if (image->stillNeedsLoad())
cache()->loader()->load(this, image, true);
}
}
}
示例3: retrieveResourcesForCSSDeclaration
void PageSerializer::retrieveResourcesForCSSDeclaration(CSSStyleDeclaration* styleDeclaration)
{
if (!styleDeclaration)
return;
if (!styleDeclaration->stylesheet()->isCSSStyleSheet())
return;
CSSStyleSheet* cssStyleSheet = static_cast<CSSStyleSheet*>(styleDeclaration->stylesheet());
// The background-image and list-style-image (for ul or ol) are the CSS properties
// that make use of images. We iterate to make sure we include any other
// image properties there might be.
for (unsigned i = 0; i < styleDeclaration->length(); ++i) {
// FIXME: It's kind of ridiculous to get the property name and then get
// the value out of the name. Ideally we would get the value out of the
// property ID, but CSSStyleDeclaration only gives access to property
// names, not IDs.
RefPtr<CSSValue> cssValue = styleDeclaration->getPropertyCSSValue(styleDeclaration->item(i));
if (!cssValue->isImageValue())
continue;
CSSImageValue* imageValue = static_cast<CSSImageValue*>(cssValue.get());
StyleImage* styleImage = imageValue->cachedOrPendingImage();
// Non cached-images are just place-holders and do not contain data.
if (!styleImage || !styleImage->isCachedImage())
continue;
CachedImage* image = static_cast<StyleCachedImage*>(styleImage)->cachedImage();
KURL url = cssStyleSheet->document()->completeURL(image->url());
addImageToResources(image, url);
}
}
示例4: ASSERT
void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRect& srcRect, const FloatRect& dstRect,
ExceptionCode& ec)
{
ASSERT(image);
ec = 0;
FloatRect imageRect = FloatRect(FloatPoint(), size(image));
if (!(imageRect.contains(srcRect) && srcRect.width() >= 0 && srcRect.height() >= 0
&& dstRect.width() >= 0 && dstRect.height() >= 0)) {
ec = INDEX_SIZE_ERR;
return;
}
if (srcRect.isEmpty() || dstRect.isEmpty())
return;
GraphicsContext* c = drawingContext();
if (!c)
return;
CachedImage* cachedImage = image->cachedImage();
if (!cachedImage)
return;
if (m_canvas->originClean())
checkOrigin(KURL(cachedImage->url()));
FloatRect sourceRect = c->roundToDevicePixels(srcRect);
FloatRect destRect = c->roundToDevicePixels(dstRect);
willDraw(destRect);
c->drawImage(cachedImage->image(), destRect, sourceRect, state().m_globalComposite);
}
示例5: checkOrigin
// FIXME: Why isn't this just another overload of drawImage? Why have a different name?
void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image,
float sx, float sy, float sw, float sh,
float dx, float dy, float dw, float dh,
const String& compositeOperation)
{
if (!image)
return;
CachedImage* cachedImage = image->cachedImage();
if (!cachedImage)
return;
if (m_canvas->originClean())
checkOrigin(KURL(cachedImage->url()));
GraphicsContext* c = drawingContext();
if (!c)
return;
CompositeOperator op;
if (!parseCompositeOperator(compositeOperation, op))
op = CompositeSourceOver;
FloatRect destRect = FloatRect(dx, dy, dw, dh);
willDraw(destRect);
c->drawImage(cachedImage->image(), destRect, FloatRect(sx, sy, sw, sh), op);
}
示例6: checkShapeImageOrigin
bool checkShapeImageOrigin(Document& document, CachedImage& cachedImage)
{
if (cachedImage.isOriginClean(document.securityOrigin()))
return true;
const URL& url = cachedImage.url();
String urlString = url.isNull() ? "''" : url.stringCenterEllipsizedToLength();
document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, "Unsafe attempt to load URL " + urlString + ".");
return false;
}
示例7: updateFromElement
void ImageLoader::updateFromElement()
{
// If we're not making renderers for the page, then don't load images. We don't want to slow
// down the raw HTML parsing case by loading images we don't intend to display.
Document* document = m_element->document();
if (!document->renderer())
return;
AtomicString attr = m_element->getAttribute(m_element->imageSourceAttributeName());
if (attr == m_failedLoadURL)
return;
// Do not load any image if the 'src' attribute is missing or if it is
// an empty string referring to a local file. The latter condition is
// a quirk that preserves old behavior that Dashboard widgets
// need (<rdar://problem/5994621>).
CachedImage* newImage = 0;
if (!(attr.isNull() || (attr.isEmpty() && document->baseURI().isLocalFile()))) {
if (m_loadManually) {
document->docLoader()->setAutoLoadImages(false);
newImage = new CachedImage(sourceURI(attr));
newImage->setLoading(true);
newImage->setDocLoader(document->docLoader());
document->docLoader()->m_documentResources.set(newImage->url(), newImage);
} else
newImage = document->docLoader()->requestImage(sourceURI(attr));
// If we do not have an image here, it means that a cross-site
// violation occurred.
m_failedLoadURL = !newImage ? attr : AtomicString();
}
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
setLoadingImage(newImage);
if (newImage) {
newImage->addClient(this);
if (!m_element->document()->hasListenerType(Document::BEFORELOAD_LISTENER))
dispatchPendingBeforeLoadEvent();
else
beforeLoadEventSender().dispatchEventSoon(this);
}
if (oldImage)
oldImage->removeClient(this);
}
if (RenderObject* renderer = m_element->renderer()) {
if (!renderer->isImage())
return;
toRenderImage(renderer)->resetAnimation();
}
}
示例8: updateFromElement
void HTMLImageLoader::updateFromElement()
{
// If we're not making renderers for the page, then don't load images. We don't want to slow
// down the raw HTML parsing case by loading images we don't intend to display.
Element* elem = element();
Document* doc = elem->document();
if (!doc->renderer())
return;
AtomicString attr = elem->getAttribute(elem->imageSourceAttributeName());
// Do not load any image if the 'src' attribute is missing or if it is
// an empty string referring to a local file. The latter condition is
// a quirk that preserves old behavior that Dashboard widgets
// need (<rdar://problem/5994621>).
CachedImage *newImage = 0;
if (!(attr.isNull() || attr.isEmpty() && doc->baseURI().isLocalFile())) {
if (m_loadManually) {
doc->docLoader()->setAutoLoadImages(false);
newImage = new CachedImage(parseURL(attr));
newImage->setLoading(true);
newImage->setDocLoader(doc->docLoader());
doc->docLoader()->m_docResources.set(newImage->url(), newImage);
} else
newImage = doc->docLoader()->requestImage(parseURL(attr));
}
CachedImage *oldImage = m_image;
if (newImage != oldImage) {
#ifdef INSTRUMENT_LAYOUT_SCHEDULING
if (!doc->ownerElement() && newImage)
OWB_PRINTF("Image requested at %d\n", doc->elapsedTime());
#endif
setLoadingImage(newImage);
if (newImage)
newImage->addClient(this);
if (oldImage)
oldImage->removeClient(this);
}
if (RenderObject* renderer = elem->renderer())
if (renderer->isImage())
static_cast<RenderImage*>(renderer)->resetAnimation();
}
示例9: updateFromElement
void HTMLImageLoader::updateFromElement()
{
// If we're not making renderers for the page, then don't load images. We don't want to slow
// down the raw HTML parsing case by loading images we don't intend to display.
Element* elem = element();
Document* doc = elem->document();
if (!doc->renderer())
return;
AtomicString attr = elem->getAttribute(elem->hasLocalName(objectTag) ? dataAttr : srcAttr);
// Treat a lack of src or empty string for src as no image at all.
CachedImage *newImage = 0;
if (!attr.isEmpty()) {
if (m_loadManually) {
doc->docLoader()->setAutoLoadImages(false);
newImage = new CachedImage(doc->docLoader(), parseURL(attr), false /* not for cache */);
newImage->setLoading(true);
newImage->setDocLoader(doc->docLoader());
doc->docLoader()->m_docResources.set(newImage->url(), newImage);
} else
newImage = doc->docLoader()->requestImage(parseURL(attr));
}
CachedImage *oldImage = m_image;
if (newImage != oldImage) {
#ifdef INSTRUMENT_LAYOUT_SCHEDULING
if (!doc->ownerElement() && newImage)
printf("Image requested at %d\n", doc->elapsedTime());
#endif
setLoadingImage(newImage);
if (newImage)
newImage->ref(this);
if (oldImage)
oldImage->deref(this);
}
if (RenderObject* renderer = elem->renderer())
if (renderer->isImage())
static_cast<RenderImage*>(renderer)->resetAnimation();
}
示例10: create
PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageElement* image,
const String& repetitionType, ExceptionCode& ec)
{
bool repeatX, repeatY;
ec = 0;
CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
if (ec)
return 0;
if (!image->complete()) {
ec = INVALID_STATE_ERR;
return 0;
}
CachedImage* cachedImage = image->cachedImage();
if (!cachedImage || !image->cachedImage()->image())
return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true);
RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(cachedImage->url());
bool originClean = m_canvas->document()->securityOrigin()->canAccess(origin.get());
return CanvasPattern::create(cachedImage->image(), repeatX, repeatY, originClean);
}
示例11: updateFromElement
void ImageLoader::updateFromElement()
{
// If we're not making renderers for the page, then don't load images. We don't want to slow
// down the raw HTML parsing case by loading images we don't intend to display.
Document* document = m_element->document();
if (!document->renderer())
return;
AtomicString attr = m_element->getAttribute(m_element->imageSourceAttributeName());
if (attr == m_failedLoadURL)
return;
// Do not load any image if the 'src' attribute is missing or if it is
// an empty string.
CachedImage* newImage = 0;
if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
ResourceRequest request = ResourceRequest(document->completeURL(sourceURI(attr)));
String crossOriginMode = m_element->fastGetAttribute(HTMLNames::crossoriginAttr);
if (!crossOriginMode.isNull()) {
StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
updateRequestForAccessControl(request, document->securityOrigin(), allowCredentials);
}
if (m_loadManually) {
bool autoLoadOtherImages = document->cachedResourceLoader()->autoLoadImages();
document->cachedResourceLoader()->setAutoLoadImages(false);
newImage = new CachedImage(request);
newImage->setLoading(true);
newImage->setOwningCachedResourceLoader(document->cachedResourceLoader());
document->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage);
document->cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages);
} else
newImage = document->cachedResourceLoader()->requestImage(request);
// If we do not have an image here, it means that a cross-site
// violation occurred.
m_failedLoadURL = !newImage ? attr : AtomicString();
} else if (!attr.isNull()) // Fire an error event if the url is empty.
m_element->dispatchEvent(Event::create(eventNames().errorEvent, false, false));
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
if (!m_firedBeforeLoad)
beforeLoadEventSender().cancelEvent(this);
if (!m_firedLoad)
loadEventSender().cancelEvent(this);
m_image = newImage;
m_firedBeforeLoad = !newImage;
m_firedLoad = !newImage;
m_imageComplete = !newImage;
if (newImage) {
if (!m_element->document()->hasListenerType(Document::BEFORELOAD_LISTENER))
dispatchPendingBeforeLoadEvent();
else
beforeLoadEventSender().dispatchEventSoon(this);
// If newImage is cached, addClient() will result in the load event
// being queued to fire. Ensure this happens after beforeload is
// dispatched.
newImage->addClient(this);
}
if (oldImage)
oldImage->removeClient(this);
}
if (RenderImageResource* imageResource = renderImageResource())
imageResource->resetAnimation();
}
示例12: updateFromElement
void ImageLoader::updateFromElement()
{
// If we're not making renderers for the page, then don't load images. We don't want to slow
// down the raw HTML parsing case by loading images we don't intend to display.
Document* document = m_element->document();
if (!document->renderer())
return;
AtomicString attr = m_element->getAttribute(m_element->imageSourceAttributeName());
if (attr == m_failedLoadURL)
return;
// Do not load any image if the 'src' attribute is missing or if it is
// an empty string referring to a local file. The latter condition is
// a quirk that preserves old behavior that Dashboard widgets
// need (<rdar://problem/5994621>).
CachedImage* newImage = 0;
// CAPPFIX_WEB_IMG_SRC_NULL
#if 1
if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
#else
if (!(attr.isNull() || (attr.isEmpty() && document->baseURI().isLocalFile()))) {
#endif
ResourceRequest request = ResourceRequest(document->completeURL(sourceURI(attr)));
String crossOriginMode = m_element->fastGetAttribute(HTMLNames::crossoriginAttr);
if (!crossOriginMode.isNull()) {
bool allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials");
updateRequestForAccessControl(request, document->securityOrigin(), allowCredentials);
}
if (m_loadManually) {
bool autoLoadOtherImages = document->cachedResourceLoader()->autoLoadImages();
document->cachedResourceLoader()->setAutoLoadImages(false);
newImage = new CachedImage(request);
newImage->setLoading(true);
newImage->setOwningCachedResourceLoader(document->cachedResourceLoader());
document->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage);
document->cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages);
} else
newImage = document->cachedResourceLoader()->requestImage(request);
// If we do not have an image here, it means that a cross-site
// violation occurred.
m_failedLoadURL = !newImage ? attr : AtomicString();
// CAPPFIX_WEB_IMG_SRC_NULL
#if 1
} else if (!attr.isNull()) // Fire an error event if the url is empty.
m_element->dispatchEvent(Event::create(eventNames().errorEvent, false, false));
#else
}
#endif
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
if (!m_firedBeforeLoad)
beforeLoadEventSender().cancelEvent(this);
if (!m_firedLoad)
loadEventSender().cancelEvent(this);
m_image = newImage;
m_firedBeforeLoad = !newImage;
m_firedLoad = !newImage;
m_imageComplete = !newImage;
if (newImage) {
newImage->addClient(this);
if (!m_element->document()->hasListenerType(Document::BEFORELOAD_LISTENER))
dispatchPendingBeforeLoadEvent();
else
beforeLoadEventSender().dispatchEventSoon(this);
}
if (oldImage)
oldImage->removeClient(this);
}
if (RenderImageResource* imageResource = renderImageResource())
imageResource->resetAnimation();
}