Ejemplo n.º 1
0
LayoutObject* ImageContentData::createLayoutObject(
    Document& doc,
    ComputedStyle& pseudoStyle) const {
  LayoutImage* image = LayoutImage::createAnonymous(&doc);
  image->setPseudoStyle(&pseudoStyle);
  if (m_image)
    image->setImageResource(
        LayoutImageResourceStyleImage::create(m_image.get()));
  else
    image->setImageResource(LayoutImageResource::create());
  return image;
}
LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style)
{
    if (m_useFallbackContent)
        return new LayoutBlockFlow(this);

    if (style.hasContent())
        return LayoutObject::createObject(this, style);

    LayoutImage* image = new LayoutImage(this);
    image->setImageResource(LayoutImageResource::create());
    image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
    return image;
}
Ejemplo n.º 3
0
static ImageResourceContent* getImageResourceContent(Element* element) {
  // Attempt to pull ImageResourceContent from element
  ASSERT(element);
  LayoutObject* layoutObject = element->layoutObject();
  if (!layoutObject || !layoutObject->isImage())
    return 0;

  LayoutImage* image = toLayoutImage(layoutObject);
  if (image->cachedImage() && !image->cachedImage()->errorOccurred())
    return image->cachedImage();

  return 0;
}
Ejemplo n.º 4
0
Image* HitTestResult::image() const
{
    Node* innerNodeOrImageMapImage = this->innerNodeOrImageMapImage();
    if (!innerNodeOrImageMapImage)
        return nullptr;

    LayoutObject* layoutObject = innerNodeOrImageMapImage->layoutObject();
    if (layoutObject && layoutObject->isImage()) {
        LayoutImage* image = toLayoutImage(layoutObject);
        if (image->cachedImage() && !image->cachedImage()->errorOccurred())
            return image->cachedImage()->image();
    }

    return nullptr;
}
Ejemplo n.º 5
0
LayoutObject* HTMLPlugInElement::createLayoutObject(
    const ComputedStyle& style) {
  // Fallback content breaks the DOM->layoutObject class relationship of this
  // class and all superclasses because createObject won't necessarily return
  // a LayoutEmbeddedObject or LayoutPart.
  if (useFallbackContent())
    return LayoutObject::createObject(this, style);

  if (isImageType()) {
    LayoutImage* image = new LayoutImage(this);
    image->setImageResource(LayoutImageResource::create());
    return image;
  }

  m_pluginIsAvailable = true;
  return new LayoutEmbeddedObject(this);
}
Ejemplo n.º 6
0
LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style)
{
    const ContentData* contentData = style.contentData();
    if (contentData && contentData->isImage()) {
        const StyleImage* contentImage = toImageContentData(contentData)->image();
        bool errorOccurred = contentImage && contentImage->cachedImage() && contentImage->cachedImage()->errorOccurred();
        if (!errorOccurred)
            return LayoutObject::createObject(this, style);
    }

    if (m_useFallbackContent)
        return new LayoutBlockFlow(this);

    LayoutImage* image = new LayoutImage(this);
    image->setImageResource(LayoutImageResource::create());
    image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
    return image;
}
Ejemplo n.º 7
0
void HTMLImageElement::attach(const AttachContext& context)
{
    HTMLElement::attach(context);

    if (layoutObject() && layoutObject()->isImage()) {
        LayoutImage* layoutImage = toLayoutImage(layoutObject());
        LayoutImageResource* layoutImageResource = layoutImage->imageResource();
        if (m_isFallbackImage) {
            float deviceScaleFactor = blink::deviceScaleFactor(layoutImage->frame());
            pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brokenImage(deviceScaleFactor);
            ImageResource* newImageResource = new ImageResource(brokenImageAndImageScaleFactor.first);
            layoutImage->imageResource()->setImageResource(newImageResource);
        }
        if (layoutImageResource->hasImage())
            return;

        if (!imageLoader().image() && !layoutImageResource->cachedImage())
            return;
        layoutImageResource->setImageResource(imageLoader().image());
    }
}
Ejemplo n.º 8
0
LayoutImage* LayoutImage::createAnonymous(Document* document)
{
    LayoutImage* image = new LayoutImage(nullptr);
    image->setDocumentForAnonymous(document);
    return image;
}