Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void PseudoElement::didRecalcStyle(StyleRecalcChange)
{
    if (!layoutObject())
        return;

    // The renderers inside pseudo elements are anonymous so they don't get notified of recalcStyle and must have
    // the style propagated downward manually similar to LayoutObject::propagateStyleToAnonymousChildren.
    LayoutObject* renderer = this->layoutObject();
    for (LayoutObject* child = renderer->nextInPreOrder(renderer); child; child = child->nextInPreOrder(renderer)) {
        // We only manage the style for the generated content items.
        if (!child->isText() && !child->isQuote() && !child->isImage())
            continue;

        child->setPseudoStyle(renderer->style());
    }
}
Exemplo n.º 4
0
void HTMLAreaElement::setFocus(bool shouldBeFocused)
{
    if (focused() == shouldBeFocused)
        return;

    HTMLAnchorElement::setFocus(shouldBeFocused);

    HTMLImageElement* imageElement = this->imageElement();
    if (!imageElement)
        return;

    LayoutObject* layoutObject = imageElement->layoutObject();
    if (!layoutObject || !layoutObject->isImage())
        return;

    toLayoutImage(layoutObject)->areaElementFocusChanged(this);
}
Exemplo n.º 5
0
LayoutImageResource* ImageLoader::layoutImageResource() {
    LayoutObject* layoutObject = m_element->layoutObject();

    if (!layoutObject)
        return 0;

    // We don't return style generated image because it doesn't belong to the
    // ImageLoader. See <https://bugs.webkit.org/show_bug.cgi?id=42840>
    if (layoutObject->isImage() &&
            !static_cast<LayoutImage*>(layoutObject)->isGeneratedContent())
        return toLayoutImage(layoutObject)->imageResource();

    if (layoutObject->isSVGImage())
        return toLayoutSVGImage(layoutObject)->imageResource();

    if (layoutObject->isVideo())
        return toLayoutVideo(layoutObject)->imageResource();

    return 0;
}
Exemplo n.º 6
0
void FirstLetterPseudoElement::didRecalcStyle(StyleRecalcChange)
{
    if (!layoutObject())
        return;

    // The layoutObjects inside pseudo elements are anonymous so they don't get notified of recalcStyle and must have
    // the style propagated downward manually similar to LayoutObject::propagateStyleToAnonymousChildren.
    LayoutObject* layoutObject = this->layoutObject();
    for (LayoutObject* child = layoutObject->nextInPreOrder(layoutObject); child; child = child->nextInPreOrder(layoutObject)) {
        // We need to re-calculate the correct style for the first letter element
        // and then apply that to the container and the text fragment inside.
        if (child->style()->styleType() == FIRST_LETTER && m_remainingTextLayoutObject) {
            if (ComputedStyle* pseudoStyle = styleForFirstLetter(m_remainingTextLayoutObject->parent()))
                child->setPseudoStyle(pseudoStyle);
            continue;
        }

        // We only manage the style for the generated content items.
        if (!child->isText() && !child->isQuote() && !child->isImage())
            continue;

        child->setPseudoStyle(layoutObject->mutableStyle());
    }
}