| 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) | 634 static bool sourceSizeValue(Element& element, Document& currentDocument, float&
sourceSize) |
| 635 { | 635 { |
| 636 String sizes = element.fastGetAttribute(sizesAttr); | 636 String sizes = element.fastGetAttribute(sizesAttr); |
| 637 bool exists = !sizes.isNull(); | 637 bool exists = !sizes.isNull(); |
| 638 if (exists) | 638 if (exists) |
| 639 UseCounter::count(currentDocument, UseCounter::Sizes); | 639 UseCounter::count(currentDocument, UseCounter::Sizes); |
| 640 sourceSize = SizesAttributeParser(MediaValuesDynamic::create(currentDocument
), sizes).length(); | 640 sourceSize = SizesAttributeParser(MediaValuesDynamic::create(currentDocument
), sizes).length(); |
| 641 return exists; | 641 return exists; |
| 642 } | 642 } |
| 643 | 643 |
| 644 int HTMLImageElement::widthAttributeToInt(const String& value, bool& isValid) | |
| 645 { | |
| 646 // '%' is excluded here since having a width percentage based value means | |
| 647 // that the actual width depends on layout, so we cannot use it for resource
Width. | |
| 648 // '*' is exclueded since in Blink and WebKit it means that the entire attri
btue is ignored. | |
| 649 // TODO(yoav): Count these occurences and try to deprecate/remove if feasibl
e: crbug.com/501870 | |
| 650 if (!value.isEmpty() && !value.contains('%') && !value.contains('*')) | |
| 651 return value.toInt(&isValid); | |
| 652 | |
| 653 isValid = false; | |
| 654 return 0; | |
| 655 } | |
| 656 | |
| 657 FetchRequest::ResourceWidth HTMLImageElement::resourceWidth() | 644 FetchRequest::ResourceWidth HTMLImageElement::resourceWidth() |
| 658 { | 645 { |
| 659 FetchRequest::ResourceWidth resourceWidth; | 646 FetchRequest::ResourceWidth resourceWidth; |
| 660 resourceWidth.isSet = sourceSizeValue(*this, document(), resourceWidth.width
); | 647 resourceWidth.isSet = sourceSizeValue(*this, document(), resourceWidth.width
); |
| 661 if (!resourceWidth.isSet) | |
| 662 resourceWidth.width = widthAttributeToInt(fastGetAttribute(widthAttr), r
esourceWidth.isSet); | |
| 663 return resourceWidth; | 648 return resourceWidth; |
| 664 } | 649 } |
| 665 | 650 |
| 666 float HTMLImageElement::sourceSize(Element& element) | 651 float HTMLImageElement::sourceSize(Element& element) |
| 667 { | 652 { |
| 668 float value; | 653 float value; |
| 669 // We don't care here if the sizes attribute exists, so we ignore the return
value. | 654 // We don't care here if the sizes attribute exists, so we ignore the return
value. |
| 670 // If it doesn't exist, we just return the default. | 655 // If it doesn't exist, we just return the default. |
| 671 sourceSizeValue(element, document(), value); | 656 sourceSizeValue(element, document(), value); |
| 672 return value; | 657 return value; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 ensureUserAgentShadowRoot(); | 746 ensureUserAgentShadowRoot(); |
| 762 } | 747 } |
| 763 | 748 |
| 764 bool HTMLImageElement::isOpaque() const | 749 bool HTMLImageElement::isOpaque() const |
| 765 { | 750 { |
| 766 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 751 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
| 767 return image && image->currentFrameKnownToBeOpaque(); | 752 return image && image->currentFrameKnownToBeOpaque(); |
| 768 } | 753 } |
| 769 | 754 |
| 770 } | 755 } |
| OLD | NEW |