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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 420 |
421 if (!layoutObject()) { | 421 if (!layoutObject()) { |
422 // check the attribute first for an explicit pixel value | 422 // check the attribute first for an explicit pixel value |
423 bool ok; | 423 bool ok; |
424 int width = getAttribute(widthAttr).toInt(&ok); | 424 int width = getAttribute(widthAttr).toInt(&ok); |
425 if (ok) | 425 if (ok) |
426 return width; | 426 return width; |
427 | 427 |
428 // if the image is available, use its width | 428 // if the image is available, use its width |
429 if (imageLoader().image()) | 429 if (imageLoader().image()) |
430 return imageLoader().image()->imageSizeForLayoutObject(layoutObject(
), 1.0f).width(); | 430 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI
mageOrientation(nullptr), 1.0f).width(); |
431 } | 431 } |
432 | 432 |
433 LayoutBox* box = layoutBox(); | 433 LayoutBox* box = layoutBox(); |
434 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth()
, box) : 0; | 434 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth()
, box) : 0; |
435 } | 435 } |
436 | 436 |
437 int HTMLImageElement::height() | 437 int HTMLImageElement::height() |
438 { | 438 { |
439 if (inActiveDocument()) | 439 if (inActiveDocument()) |
440 document().updateLayoutIgnorePendingStylesheets(); | 440 document().updateLayoutIgnorePendingStylesheets(); |
441 | 441 |
442 if (!layoutObject()) { | 442 if (!layoutObject()) { |
443 // check the attribute first for an explicit pixel value | 443 // check the attribute first for an explicit pixel value |
444 bool ok; | 444 bool ok; |
445 int height = getAttribute(heightAttr).toInt(&ok); | 445 int height = getAttribute(heightAttr).toInt(&ok); |
446 if (ok) | 446 if (ok) |
447 return height; | 447 return height; |
448 | 448 |
449 // if the image is available, use its height | 449 // if the image is available, use its height |
450 if (imageLoader().image()) | 450 if (imageLoader().image()) |
451 return imageLoader().image()->imageSizeForLayoutObject(layoutObject(
), 1.0f).height(); | 451 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI
mageOrientation(nullptr), 1.0f).height(); |
452 } | 452 } |
453 | 453 |
454 LayoutBox* box = layoutBox(); | 454 LayoutBox* box = layoutBox(); |
455 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(
), box) : 0; | 455 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(
), box) : 0; |
456 } | 456 } |
457 | 457 |
458 int HTMLImageElement::naturalWidth() const | 458 int HTMLImageElement::naturalWidth() const |
459 { | 459 { |
460 if (!imageLoader().image()) | 460 if (!imageLoader().image()) |
461 return 0; | 461 return 0; |
462 | 462 |
463 return imageLoader().image()->imageSizeForLayoutObject(layoutObject(), m_ima
geDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).width(); | 463 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie
ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec
tedToDPR).width(); |
464 } | 464 } |
465 | 465 |
466 int HTMLImageElement::naturalHeight() const | 466 int HTMLImageElement::naturalHeight() const |
467 { | 467 { |
468 if (!imageLoader().image()) | 468 if (!imageLoader().image()) |
469 return 0; | 469 return 0; |
470 | 470 |
471 return imageLoader().image()->imageSizeForLayoutObject(layoutObject(), m_ima
geDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).height(); | 471 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie
ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec
tedToDPR).height(); |
472 } | 472 } |
473 | 473 |
474 const String& HTMLImageElement::currentSrc() const | 474 const String& HTMLImageElement::currentSrc() const |
475 { | 475 { |
476 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do
m-img-currentsrc | 476 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do
m-img-currentsrc |
477 // The currentSrc IDL attribute must return the img element's current reques
t's current URL. | 477 // The currentSrc IDL attribute must return the img element's current reques
t's current URL. |
478 // Initially, the pending request turns into current request when it is eith
er available or broken. | 478 // Initially, the pending request turns into current request when it is eith
er available or broken. |
479 // We use the image's dimensions as a proxy to it being in any of these stat
es. | 479 // We use the image's dimensions as a proxy to it being in any of these stat
es. |
480 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade
r().image()->image()->width()) | 480 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade
r().image()->image()->width()) |
481 return emptyAtom; | 481 return emptyAtom; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 return false; | 620 return false; |
621 return !image->isAccessAllowed(destinationSecurityOrigin); | 621 return !image->isAccessAllowed(destinationSecurityOrigin); |
622 } | 622 } |
623 | 623 |
624 FloatSize HTMLImageElement::elementSize() const | 624 FloatSize HTMLImageElement::elementSize() const |
625 { | 625 { |
626 ImageResource* image = cachedImage(); | 626 ImageResource* image = cachedImage(); |
627 if (!image) | 627 if (!image) |
628 return FloatSize(); | 628 return FloatSize(); |
629 | 629 |
630 return FloatSize(image->imageSizeForLayoutObject(layoutObject(), 1.0f)); | 630 return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientatio
n(layoutObject()), 1.0f)); |
631 } | 631 } |
632 | 632 |
633 FloatSize HTMLImageElement::defaultDestinationSize() const | 633 FloatSize HTMLImageElement::defaultDestinationSize() const |
634 { | 634 { |
635 ImageResource* image = cachedImage(); | 635 ImageResource* image = cachedImage(); |
636 if (!image) | 636 if (!image) |
637 return FloatSize(); | 637 return FloatSize(); |
638 LayoutSize size; | 638 LayoutSize size; |
639 size = image->imageSizeForLayoutObject(layoutObject(), 1.0f); | 639 size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutOb
ject()), 1.0f); |
640 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeWidth()) | 640 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeWidth()) |
641 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); | 641 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); |
642 return FloatSize(size); | 642 return FloatSize(size); |
643 } | 643 } |
644 | 644 |
645 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) | 645 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) |
646 { | 646 { |
647 String sizes = element.fastGetAttribute(sizesAttr); | 647 String sizes = element.fastGetAttribute(sizesAttr); |
648 bool exists = !sizes.isNull(); | 648 bool exists = !sizes.isNull(); |
649 if (exists) | 649 if (exists) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 ensureUserAgentShadowRoot(); | 769 ensureUserAgentShadowRoot(); |
770 } | 770 } |
771 | 771 |
772 bool HTMLImageElement::isOpaque() const | 772 bool HTMLImageElement::isOpaque() const |
773 { | 773 { |
774 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 774 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
775 return image && image->currentFrameKnownToBeOpaque(); | 775 return image && image->currentFrameKnownToBeOpaque(); |
776 } | 776 } |
777 | 777 |
778 } | 778 } |
OLD | NEW |