| 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 ImageResource* image = cachedImage(); | 623 ImageResource* image = cachedImage(); |
| 624 if (!image) | 624 if (!image) |
| 625 return FloatSize(); | 625 return FloatSize(); |
| 626 LayoutSize size; | 626 LayoutSize size; |
| 627 size = image->imageSizeForLayoutObject(layoutObject(), 1.0f); | 627 size = image->imageSizeForLayoutObject(layoutObject(), 1.0f); |
| 628 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeWidth()) | 628 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeWidth()) |
| 629 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); | 629 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); |
| 630 return FloatSize(size); | 630 return FloatSize(size); |
| 631 } | 631 } |
| 632 | 632 |
| 633 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) |
| 634 { |
| 635 String sizes = element.fastGetAttribute(sizesAttr); |
| 636 bool exists = !sizes.isNull(); |
| 637 if (exists) |
| 638 UseCounter::count(currentDocument, UseCounter::Sizes); |
| 639 sourceSize = SizesAttributeParser(MediaValuesDynamic::create(currentDocument
), sizes).length(); |
| 640 return exists; |
| 641 } |
| 642 |
| 643 int HTMLImageElement::widthAttributeToInt(const String& value, bool& isValid) |
| 644 { |
| 645 if (!value.isEmpty() && !value.contains('%') && !value.contains('*')) |
| 646 return value.toInt(&isValid); |
| 647 |
| 648 isValid = false; |
| 649 return 0; |
| 650 } |
| 651 |
| 652 FetchRequest::ResourceWidth HTMLImageElement::resourceWidth() |
| 653 { |
| 654 FetchRequest::ResourceWidth resourceWidth; |
| 655 resourceWidth.isSet = sourceSizeValue(*this, document(), resourceWidth.width
); |
| 656 if (!resourceWidth.isSet) |
| 657 resourceWidth.width = widthAttributeToInt(fastGetAttribute(widthAttr), r
esourceWidth.isSet); |
| 658 return resourceWidth; |
| 659 } |
| 660 |
| 633 float HTMLImageElement::sourceSize(Element& element) | 661 float HTMLImageElement::sourceSize(Element& element) |
| 634 { | 662 { |
| 635 String sizes = element.fastGetAttribute(sizesAttr); | 663 float value; |
| 636 if (!sizes.isNull()) | 664 // We don't care here if the sizes attribute exists, so we ignore the return
value. |
| 637 UseCounter::count(document(), UseCounter::Sizes); | 665 // If it doesn't exist, we just return the default. |
| 638 return SizesAttributeParser(MediaValuesDynamic::create(document()), sizes).l
ength(); | 666 sourceSizeValue(element, document(), value); |
| 667 return value; |
| 639 } | 668 } |
| 640 | 669 |
| 641 void HTMLImageElement::forceReload() const | 670 void HTMLImageElement::forceReload() const |
| 642 { | 671 { |
| 643 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload); | 672 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload); |
| 644 } | 673 } |
| 645 | 674 |
| 646 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) | 675 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) |
| 647 { | 676 { |
| 648 if (!document().isActive()) | 677 if (!document().isActive()) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 ensureUserAgentShadowRoot(); | 756 ensureUserAgentShadowRoot(); |
| 728 } | 757 } |
| 729 | 758 |
| 730 bool HTMLImageElement::isOpaque() const | 759 bool HTMLImageElement::isOpaque() const |
| 731 { | 760 { |
| 732 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 761 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
| 733 return image && image->currentFrameKnownToBeOpaque(); | 762 return image && image->currentFrameKnownToBeOpaque(); |
| 734 } | 763 } |
| 735 | 764 |
| 736 } | 765 } |
| OLD | NEW |