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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 432 |
433 if (!layoutObject()) { | 433 if (!layoutObject()) { |
434 // check the attribute first for an explicit pixel value | 434 // check the attribute first for an explicit pixel value |
435 bool ok; | 435 bool ok; |
436 int width = getAttribute(widthAttr).toInt(&ok); | 436 int width = getAttribute(widthAttr).toInt(&ok); |
437 if (ok) | 437 if (ok) |
438 return width; | 438 return width; |
439 | 439 |
440 // if the image is available, use its width | 440 // if the image is available, use its width |
441 if (imageLoader().image()) | 441 if (imageLoader().image()) |
442 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI
mageOrientation(nullptr), 1.0f).width(); | 442 return imageLoader().image()->defaultConcreteObjectSize(LayoutObject
::shouldRespectImageOrientation(nullptr), 1.0f).width(); |
443 } | 443 } |
444 | 444 |
445 LayoutBox* box = layoutBox(); | 445 LayoutBox* box = layoutBox(); |
446 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth()
, box) : 0; | 446 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth()
, box) : 0; |
447 } | 447 } |
448 | 448 |
449 int HTMLImageElement::height() | 449 int HTMLImageElement::height() |
450 { | 450 { |
451 if (inActiveDocument()) | 451 if (inActiveDocument()) |
452 document().updateLayoutIgnorePendingStylesheets(); | 452 document().updateLayoutIgnorePendingStylesheets(); |
453 | 453 |
454 if (!layoutObject()) { | 454 if (!layoutObject()) { |
455 // check the attribute first for an explicit pixel value | 455 // check the attribute first for an explicit pixel value |
456 bool ok; | 456 bool ok; |
457 int height = getAttribute(heightAttr).toInt(&ok); | 457 int height = getAttribute(heightAttr).toInt(&ok); |
458 if (ok) | 458 if (ok) |
459 return height; | 459 return height; |
460 | 460 |
461 // if the image is available, use its height | 461 // if the image is available, use its height |
462 if (imageLoader().image()) | 462 if (imageLoader().image()) |
463 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI
mageOrientation(nullptr), 1.0f).height(); | 463 return imageLoader().image()->defaultConcreteObjectSize(LayoutObject
::shouldRespectImageOrientation(nullptr), 1.0f).height(); |
464 } | 464 } |
465 | 465 |
466 LayoutBox* box = layoutBox(); | 466 LayoutBox* box = layoutBox(); |
467 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(
), box) : 0; | 467 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(
), box) : 0; |
468 } | 468 } |
469 | 469 |
470 int HTMLImageElement::naturalWidth() const | 470 int HTMLImageElement::naturalWidth() const |
471 { | 471 { |
472 if (!imageLoader().image()) | 472 if (!imageLoader().image()) |
473 return 0; | 473 return 0; |
474 | 474 |
475 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie
ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec
tedToDPR).width(); | 475 return imageLoader().image()->defaultConcreteObjectSize(LayoutObject::should
RespectImageOrientation(layoutObject()), m_imageDevicePixelRatio, ImageResource:
:IntrinsicCorrectedToDPR).width(); |
476 } | 476 } |
477 | 477 |
478 int HTMLImageElement::naturalHeight() const | 478 int HTMLImageElement::naturalHeight() const |
479 { | 479 { |
480 if (!imageLoader().image()) | 480 if (!imageLoader().image()) |
481 return 0; | 481 return 0; |
482 | 482 |
483 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie
ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec
tedToDPR).height(); | 483 return imageLoader().image()->defaultConcreteObjectSize(LayoutObject::should
RespectImageOrientation(layoutObject()), m_imageDevicePixelRatio, ImageResource:
:IntrinsicCorrectedToDPR).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()->image() || !imageLoade
r().image()->image()->defaultConcreteObjectSizeWidth()) |
493 return emptyAtom; | 493 return emptyAtom; |
494 | 494 |
495 return imageLoader().image()->url().string(); | 495 return imageLoader().image()->url().string(); |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 sourceImage = SVGImageForContainer::create(toSVGImage(cachedImage()->ima
ge()), |
621 cachedImage()->image()->size(), 1, document().completeURL(imageSourc
eURL())); | 621 cachedImage()->image()->defaultConcreteObjectSize(), 1, document().c
ompleteURL(imageSourceURL())); |
622 } else { | 622 } else { |
623 sourceImage = cachedImage()->image(); | 623 sourceImage = cachedImage()->image(); |
624 } | 624 } |
625 | 625 |
626 *status = NormalSourceImageStatus; | 626 *status = NormalSourceImageStatus; |
627 return sourceImage->imageForDefaultFrame(); | 627 return sourceImage->imageForDefaultFrame(); |
628 } | 628 } |
629 | 629 |
630 bool HTMLImageElement::isSVGSource() const | 630 bool HTMLImageElement::isSVGSource() const |
631 { | 631 { |
632 return cachedImage() && cachedImage()->image()->isSVGImage(); | 632 return cachedImage() && cachedImage()->image()->isSVGImage(); |
633 } | 633 } |
634 | 634 |
635 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi
n) const | 635 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi
n) const |
636 { | 636 { |
637 ImageResource* image = cachedImage(); | 637 ImageResource* image = cachedImage(); |
638 if (!image) | 638 if (!image) |
639 return false; | 639 return false; |
640 return !image->isAccessAllowed(destinationSecurityOrigin); | 640 return !image->isAccessAllowed(destinationSecurityOrigin); |
641 } | 641 } |
642 | 642 |
643 FloatSize HTMLImageElement::elementSize() const | 643 FloatSize HTMLImageElement::elementSize(const FloatSize& defaultObjectSize) cons
t |
644 { | 644 { |
645 ImageResource* image = cachedImage(); | 645 ImageResource* image = cachedImage(); |
646 if (!image) | 646 if (!image) |
647 return FloatSize(); | 647 return FloatSize(); |
648 | 648 |
649 return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientatio
n(layoutObject()), 1.0f)); | 649 return FloatSize(image->concreteObjectSize(defaultObjectSize, LayoutObject::
shouldRespectImageOrientation(layoutObject()), 1.0f)); |
650 } | 650 } |
651 | 651 |
652 FloatSize HTMLImageElement::defaultDestinationSize() const | 652 FloatSize HTMLImageElement::defaultDestinationSize(const FloatSize& defaultObjec
tSize) const |
653 { | 653 { |
654 ImageResource* image = cachedImage(); | 654 ImageResource* image = cachedImage(); |
655 if (!image) | 655 if (!image) |
656 return FloatSize(); | 656 return FloatSize(); |
657 LayoutSize size; | 657 LayoutSize size; |
658 size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutOb
ject()), 1.0f); | 658 size = image->concreteObjectSize(defaultObjectSize, LayoutObject::shouldResp
ectImageOrientation(layoutObject()), 1.0f); |
659 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeSize()) | 659 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeSize()) |
660 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); | 660 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); |
661 return FloatSize(size); | 661 return FloatSize(size); |
662 } | 662 } |
663 | 663 |
664 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) | 664 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) |
665 { | 665 { |
666 String sizes = element.fastGetAttribute(sizesAttr); | 666 String sizes = element.fastGetAttribute(sizesAttr); |
667 bool exists = !sizes.isNull(); | 667 bool exists = !sizes.isNull(); |
668 if (exists) | 668 if (exists) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 { | 806 { |
807 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 807 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
808 return image && image->currentFrameKnownToBeOpaque(); | 808 return image && image->currentFrameKnownToBeOpaque(); |
809 } | 809 } |
810 | 810 |
811 IntSize HTMLImageElement::bitmapSourceSize() const | 811 IntSize HTMLImageElement::bitmapSourceSize() const |
812 { | 812 { |
813 ImageResource* image = cachedImage(); | 813 ImageResource* image = cachedImage(); |
814 if (!image) | 814 if (!image) |
815 return IntSize(); | 815 return IntSize(); |
816 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); | 816 LayoutSize lSize = image->defaultConcreteObjectSize(LayoutObject::shouldResp
ectImageOrientation(layoutObject()), 1.0f); |
817 ASSERT(lSize.fraction().isZero()); | 817 ASSERT(lSize.fraction().isZero()); |
818 return IntSize(lSize.width(), lSize.height()); | 818 return IntSize(lSize.width(), lSize.height()); |
819 } | 819 } |
820 | 820 |
821 } // namespace blink | 821 } // namespace blink |
OLD | NEW |