| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 return nullptr; | 596 return nullptr; |
| 597 | 597 |
| 598 return imageLoader().image()->image(); | 598 return imageLoader().image()->image(); |
| 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 | 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()->image()->isSVGImage()) { |
| 620 sourceImage = SVGImageForContainer::create(toSVGImage(cachedImage()->ima
ge()), | 620 SVGImage* svgImage = toSVGImage(cachedImage()->image()); |
| 621 cachedImage()->image()->size(), 1, document().completeURL(imageSourc
eURL())); | 621 IntSize imageSize = roundedIntSize(svgImage->concreteObjectSize(defaultO
bjectSize)); |
| 622 sourceImage = SVGImageForContainer::create(svgImage, |
| 623 imageSize, 1, document().completeURL(imageSourceURL())); |
| 622 } else { | 624 } else { |
| 623 sourceImage = cachedImage()->image(); | 625 sourceImage = cachedImage()->image(); |
| 624 } | 626 } |
| 625 | 627 |
| 626 *status = NormalSourceImageStatus; | 628 *status = NormalSourceImageStatus; |
| 627 return sourceImage->imageForDefaultFrame(); | 629 return sourceImage->imageForDefaultFrame(); |
| 628 } | 630 } |
| 629 | 631 |
| 630 bool HTMLImageElement::isSVGSource() const | 632 bool HTMLImageElement::isSVGSource() const |
| 631 { | 633 { |
| 632 return cachedImage() && cachedImage()->image()->isSVGImage(); | 634 return cachedImage() && cachedImage()->image()->isSVGImage(); |
| 633 } | 635 } |
| 634 | 636 |
| 635 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi
n) const | 637 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi
n) const |
| 636 { | 638 { |
| 637 ImageResource* image = cachedImage(); | 639 ImageResource* image = cachedImage(); |
| 638 if (!image) | 640 if (!image) |
| 639 return false; | 641 return false; |
| 640 return !image->isAccessAllowed(destinationSecurityOrigin); | 642 return !image->isAccessAllowed(destinationSecurityOrigin); |
| 641 } | 643 } |
| 642 | 644 |
| 643 FloatSize HTMLImageElement::elementSize() const | 645 FloatSize HTMLImageElement::elementSize(const FloatSize& defaultObjectSize) cons
t |
| 644 { | 646 { |
| 645 ImageResource* image = cachedImage(); | 647 ImageResource* image = cachedImage(); |
| 646 if (!image) | 648 if (!image) |
| 647 return FloatSize(); | 649 return FloatSize(); |
| 648 | 650 |
| 651 if (image->image() && image->image()->isSVGImage()) |
| 652 return toSVGImage(cachedImage()->image())->concreteObjectSize(defaultObj
ectSize); |
| 653 |
| 649 return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientatio
n(layoutObject()), 1.0f)); | 654 return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientatio
n(layoutObject()), 1.0f)); |
| 650 } | 655 } |
| 651 | 656 |
| 652 FloatSize HTMLImageElement::defaultDestinationSize() const | 657 FloatSize HTMLImageElement::defaultDestinationSize(const FloatSize& defaultObjec
tSize) const |
| 653 { | 658 { |
| 654 ImageResource* image = cachedImage(); | 659 ImageResource* image = cachedImage(); |
| 655 if (!image) | 660 if (!image) |
| 656 return FloatSize(); | 661 return FloatSize(); |
| 662 |
| 663 if (image->image() && image->image()->isSVGImage()) |
| 664 return toSVGImage(cachedImage()->image())->concreteObjectSize(defaultObj
ectSize); |
| 665 |
| 657 LayoutSize size; | 666 LayoutSize size; |
| 658 size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutOb
ject()), 1.0f); | 667 size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutOb
ject()), 1.0f); |
| 659 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeSize()) | 668 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeSize()) |
| 660 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); | 669 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); |
| 661 return FloatSize(size); | 670 return FloatSize(size); |
| 662 } | 671 } |
| 663 | 672 |
| 664 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) | 673 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) |
| 665 { | 674 { |
| 666 String sizes = element.fastGetAttribute(sizesAttr); | 675 String sizes = element.fastGetAttribute(sizesAttr); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 { | 821 { |
| 813 ImageResource* image = cachedImage(); | 822 ImageResource* image = cachedImage(); |
| 814 if (!image) | 823 if (!image) |
| 815 return IntSize(); | 824 return IntSize(); |
| 816 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); | 825 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); |
| 817 ASSERT(lSize.fraction().isZero()); | 826 ASSERT(lSize.fraction().isZero()); |
| 818 return IntSize(lSize.width(), lSize.height()); | 827 return IntSize(lSize.width(), lSize.height()); |
| 819 } | 828 } |
| 820 | 829 |
| 821 } // namespace blink | 830 } // namespace blink |
| OLD | NEW |