OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 482 |
483 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie
ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec
tedToDPR).height(); | 483 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie
ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec
tedToDPR).height(); |
484 } | 484 } |
485 | 485 |
486 const String& HTMLImageElement::currentSrc() const | 486 const String& HTMLImageElement::currentSrc() const |
487 { | 487 { |
488 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do
m-img-currentsrc | 488 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do
m-img-currentsrc |
489 // The currentSrc IDL attribute must return the img element's current reques
t's current URL. | 489 // The currentSrc IDL attribute must return the img element's current reques
t's current URL. |
490 // Initially, the pending request turns into current request when it is eith
er available or broken. | 490 // Initially, the pending request turns into current request when it is eith
er available or broken. |
491 // We use the image's dimensions as a proxy to it being in any of these stat
es. | 491 // We use the image's dimensions as a proxy to it being in any of these stat
es. |
492 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade
r().image()->image()->width()) | 492 if (!imageLoader().image() || !imageLoader().image()->getImage() || !imageLo
ader().image()->getImage()->width()) |
493 return emptyAtom; | 493 return emptyAtom; |
494 | 494 |
495 return imageLoader().image()->url().getString(); | 495 return imageLoader().image()->url().getString(); |
496 } | 496 } |
497 | 497 |
498 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const | 498 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const |
499 { | 499 { |
500 return attribute.name() == srcAttr | 500 return attribute.name() == srcAttr |
501 || attribute.name() == lowsrcAttr | 501 || attribute.name() == lowsrcAttr |
502 || attribute.name() == longdescAttr | 502 || attribute.name() == longdescAttr |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 return false; | 588 return false; |
589 | 589 |
590 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)).isE
mpty(); | 590 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)).isE
mpty(); |
591 } | 591 } |
592 | 592 |
593 Image* HTMLImageElement::imageContents() | 593 Image* HTMLImageElement::imageContents() |
594 { | 594 { |
595 if (!imageLoader().imageComplete()) | 595 if (!imageLoader().imageComplete()) |
596 return nullptr; | 596 return nullptr; |
597 | 597 |
598 return imageLoader().image()->image(); | 598 return imageLoader().image()->getImage(); |
599 } | 599 } |
600 | 600 |
601 bool HTMLImageElement::isInteractiveContent() const | 601 bool HTMLImageElement::isInteractiveContent() const |
602 { | 602 { |
603 return fastHasAttribute(usemapAttr); | 603 return fastHasAttribute(usemapAttr); |
604 } | 604 } |
605 | 605 |
606 PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageStatus* s
tatus, AccelerationHint, SnapshotReason, const FloatSize& defaultObjectSize) con
st | 606 PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageStatus* s
tatus, AccelerationHint, SnapshotReason, const FloatSize& defaultObjectSize) con
st |
607 { | 607 { |
608 if (!complete() || !cachedImage()) { | 608 if (!complete() || !cachedImage()) { |
609 *status = IncompleteSourceImageStatus; | 609 *status = IncompleteSourceImageStatus; |
610 return nullptr; | 610 return nullptr; |
611 } | 611 } |
612 | 612 |
613 if (cachedImage()->errorOccurred()) { | 613 if (cachedImage()->errorOccurred()) { |
614 *status = UndecodableSourceImageStatus; | 614 *status = UndecodableSourceImageStatus; |
615 return nullptr; | 615 return nullptr; |
616 } | 616 } |
617 | 617 |
618 RefPtr<Image> sourceImage; | 618 RefPtr<Image> sourceImage; |
619 if (cachedImage()->image()->isSVGImage()) { | 619 if (cachedImage()->getImage()->isSVGImage()) { |
620 SVGImage* svgImage = toSVGImage(cachedImage()->image()); | 620 SVGImage* svgImage = toSVGImage(cachedImage()->getImage()); |
621 IntSize imageSize = roundedIntSize(svgImage->concreteObjectSize(defaultO
bjectSize)); | 621 IntSize imageSize = roundedIntSize(svgImage->concreteObjectSize(defaultO
bjectSize)); |
622 sourceImage = SVGImageForContainer::create(svgImage, | 622 sourceImage = SVGImageForContainer::create(svgImage, |
623 imageSize, 1, document().completeURL(imageSourceURL())); | 623 imageSize, 1, document().completeURL(imageSourceURL())); |
624 } else { | 624 } else { |
625 sourceImage = cachedImage()->image(); | 625 sourceImage = cachedImage()->getImage(); |
626 } | 626 } |
627 | 627 |
628 *status = NormalSourceImageStatus; | 628 *status = NormalSourceImageStatus; |
629 return sourceImage->imageForDefaultFrame(); | 629 return sourceImage->imageForDefaultFrame(); |
630 } | 630 } |
631 | 631 |
632 bool HTMLImageElement::isSVGSource() const | 632 bool HTMLImageElement::isSVGSource() const |
633 { | 633 { |
634 return cachedImage() && cachedImage()->image()->isSVGImage(); | 634 return cachedImage() && cachedImage()->getImage()->isSVGImage(); |
635 } | 635 } |
636 | 636 |
637 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi
n) const | 637 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi
n) const |
638 { | 638 { |
639 ImageResource* image = cachedImage(); | 639 ImageResource* image = cachedImage(); |
640 if (!image) | 640 if (!image) |
641 return false; | 641 return false; |
642 return !image->isAccessAllowed(destinationSecurityOrigin); | 642 return !image->isAccessAllowed(destinationSecurityOrigin); |
643 } | 643 } |
644 | 644 |
645 FloatSize HTMLImageElement::elementSize(const FloatSize& defaultObjectSize) cons
t | 645 FloatSize HTMLImageElement::elementSize(const FloatSize& defaultObjectSize) cons
t |
646 { | 646 { |
647 ImageResource* image = cachedImage(); | 647 ImageResource* image = cachedImage(); |
648 if (!image) | 648 if (!image) |
649 return FloatSize(); | 649 return FloatSize(); |
650 | 650 |
651 if (image->image() && image->image()->isSVGImage()) | 651 if (image->getImage() && image->getImage()->isSVGImage()) |
652 return toSVGImage(cachedImage()->image())->concreteObjectSize(defaultObj
ectSize); | 652 return toSVGImage(cachedImage()->getImage())->concreteObjectSize(default
ObjectSize); |
653 | 653 |
654 return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientatio
n(layoutObject()), 1.0f)); | 654 return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientatio
n(layoutObject()), 1.0f)); |
655 } | 655 } |
656 | 656 |
657 FloatSize HTMLImageElement::defaultDestinationSize(const FloatSize& defaultObjec
tSize) const | 657 FloatSize HTMLImageElement::defaultDestinationSize(const FloatSize& defaultObjec
tSize) const |
658 { | 658 { |
659 ImageResource* image = cachedImage(); | 659 ImageResource* image = cachedImage(); |
660 if (!image) | 660 if (!image) |
661 return FloatSize(); | 661 return FloatSize(); |
662 | 662 |
663 if (image->image() && image->image()->isSVGImage()) | 663 if (image->getImage() && image->getImage()->isSVGImage()) |
664 return toSVGImage(cachedImage()->image())->concreteObjectSize(defaultObj
ectSize); | 664 return toSVGImage(cachedImage()->getImage())->concreteObjectSize(default
ObjectSize); |
665 | 665 |
666 LayoutSize size; | 666 LayoutSize size; |
667 size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutOb
ject()), 1.0f); | 667 size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutOb
ject()), 1.0f); |
668 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeSize()) | 668 if (layoutObject() && layoutObject()->isLayoutImage() && image->getImage() &
& !image->getImage()->hasRelativeSize()) |
669 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); | 669 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); |
670 return FloatSize(size); | 670 return FloatSize(size); |
671 } | 671 } |
672 | 672 |
673 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) | 673 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) |
674 { | 674 { |
675 String sizes = element.fastGetAttribute(sizesAttr); | 675 String sizes = element.fastGetAttribute(sizesAttr); |
676 bool exists = !sizes.isNull(); | 676 bool exists = !sizes.isNull(); |
677 if (exists) | 677 if (exists) |
678 UseCounter::count(currentDocument, UseCounter::Sizes); | 678 UseCounter::count(currentDocument, UseCounter::Sizes); |
(...skipping 25 matching lines...) Expand all Loading... |
704 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP
olicy); | 704 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP
olicy); |
705 } | 705 } |
706 | 706 |
707 ScriptPromise HTMLImageElement::createImageBitmap(ScriptState* scriptState, Even
tTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions&
options, ExceptionState& exceptionState) | 707 ScriptPromise HTMLImageElement::createImageBitmap(ScriptState* scriptState, Even
tTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions&
options, ExceptionState& exceptionState) |
708 { | 708 { |
709 ASSERT(eventTarget.toDOMWindow()); | 709 ASSERT(eventTarget.toDOMWindow()); |
710 if (!cachedImage()) { | 710 if (!cachedImage()) { |
711 exceptionState.throwDOMException(InvalidStateError, "No image can be ret
rieved from the provided element."); | 711 exceptionState.throwDOMException(InvalidStateError, "No image can be ret
rieved from the provided element."); |
712 return ScriptPromise(); | 712 return ScriptPromise(); |
713 } | 713 } |
714 if (cachedImage()->image()->isSVGImage()) { | 714 if (cachedImage()->getImage()->isSVGImage()) { |
715 exceptionState.throwDOMException(InvalidStateError, "The image element c
ontains an SVG image, which is unsupported."); | 715 exceptionState.throwDOMException(InvalidStateError, "The image element c
ontains an SVG image, which is unsupported."); |
716 return ScriptPromise(); | 716 return ScriptPromise(); |
717 } | 717 } |
718 if (!sw || !sh) { | 718 if (!sw || !sh) { |
719 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); | 719 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); |
720 return ScriptPromise(); | 720 return ScriptPromise(); |
721 } | 721 } |
722 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh), eventTarget.toDOMWindow()->document(), options)
); | 722 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh), eventTarget.toDOMWindow()->document(), options)
); |
723 } | 723 } |
724 | 724 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 { | 821 { |
822 ImageResource* image = cachedImage(); | 822 ImageResource* image = cachedImage(); |
823 if (!image) | 823 if (!image) |
824 return IntSize(); | 824 return IntSize(); |
825 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); | 825 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); |
826 ASSERT(lSize.fraction().isZero()); | 826 ASSERT(lSize.fraction().isZero()); |
827 return IntSize(lSize.width(), lSize.height()); | 827 return IntSize(lSize.width(), lSize.height()); |
828 } | 828 } |
829 | 829 |
830 } // namespace blink | 830 } // namespace blink |
OLD | NEW |