| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 String srcset = source->fastGetAttribute(srcsetAttr); | 313 String srcset = source->fastGetAttribute(srcsetAttr); |
| 314 if (srcset.isEmpty()) | 314 if (srcset.isEmpty()) |
| 315 continue; | 315 continue; |
| 316 String type = source->fastGetAttribute(typeAttr); | 316 String type = source->fastGetAttribute(typeAttr); |
| 317 if (!type.isEmpty() && !supportedImageType(type)) | 317 if (!type.isEmpty() && !supportedImageType(type)) |
| 318 continue; | 318 continue; |
| 319 | 319 |
| 320 if (!source->mediaQueryMatches()) | 320 if (!source->mediaQueryMatches()) |
| 321 continue; | 321 continue; |
| 322 | 322 |
| 323 String sizes = source->fastGetAttribute(sizesAttr); | 323 ImageCandidate candidate = bestFitSourceForSrcsetAttribute(document().de
vicePixelRatio(), sourceSize(*source), source->fastGetAttribute(srcsetAttr), &do
cument()); |
| 324 if (!sizes.isNull()) | |
| 325 UseCounter::count(document(), UseCounter::Sizes); | |
| 326 SizesAttributeParser parser = SizesAttributeParser(MediaValuesDynamic::c
reate(document()), sizes); | |
| 327 float effectiveSize = parser.length(); | |
| 328 ImageCandidate candidate = bestFitSourceForSrcsetAttribute(document().de
vicePixelRatio(), effectiveSize, source->fastGetAttribute(srcsetAttr), &document
()); | |
| 329 if (candidate.isEmpty()) | 324 if (candidate.isEmpty()) |
| 330 continue; | 325 continue; |
| 331 return candidate; | 326 return candidate; |
| 332 } | 327 } |
| 333 return ImageCandidate(); | 328 return ImageCandidate(); |
| 334 } | 329 } |
| 335 | 330 |
| 336 LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style) | 331 LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style) |
| 337 { | 332 { |
| 338 if (style.hasContent()) | 333 if (style.hasContent()) |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 ImageResource* image = cachedImage(); | 623 ImageResource* image = cachedImage(); |
| 629 if (!image) | 624 if (!image) |
| 630 return FloatSize(); | 625 return FloatSize(); |
| 631 LayoutSize size; | 626 LayoutSize size; |
| 632 size = image->imageSizeForLayoutObject(layoutObject(), 1.0f); | 627 size = image->imageSizeForLayoutObject(layoutObject(), 1.0f); |
| 633 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeWidth()) | 628 if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !
image->image()->hasRelativeWidth()) |
| 634 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); | 629 size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); |
| 635 return FloatSize(size); | 630 return FloatSize(size); |
| 636 } | 631 } |
| 637 | 632 |
| 633 float HTMLImageElement::sourceSize(Element& element) |
| 634 { |
| 635 String sizes = element.fastGetAttribute(sizesAttr); |
| 636 if (!sizes.isNull()) |
| 637 UseCounter::count(document(), UseCounter::Sizes); |
| 638 return SizesAttributeParser(MediaValuesDynamic::create(document()), sizes).l
ength(); |
| 639 } |
| 640 |
| 638 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) | 641 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) |
| 639 { | 642 { |
| 640 if (!document().isActive()) | 643 if (!document().isActive()) |
| 641 return; | 644 return; |
| 642 | 645 |
| 643 bool foundURL = false; | 646 bool foundURL = false; |
| 644 if (RuntimeEnabledFeatures::pictureEnabled()) { | 647 if (RuntimeEnabledFeatures::pictureEnabled()) { |
| 645 ImageCandidate candidate = findBestFitImageFromPictureParent(); | 648 ImageCandidate candidate = findBestFitImageFromPictureParent(); |
| 646 if (!candidate.isEmpty()) { | 649 if (!candidate.isEmpty()) { |
| 647 setBestFitURLAndDPRFromImageCandidate(candidate); | 650 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 648 foundURL = true; | 651 foundURL = true; |
| 649 } | 652 } |
| 650 } | 653 } |
| 651 | 654 |
| 652 if (!foundURL) { | 655 if (!foundURL) { |
| 653 String sizes = fastGetAttribute(sizesAttr); | 656 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de
vicePixelRatio(), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute
(srcsetAttr), &document()); |
| 654 if (!sizes.isNull()) | |
| 655 UseCounter::count(document(), UseCounter::Sizes); | |
| 656 SizesAttributeParser parser = SizesAttributeParser(MediaValuesDynamic::c
reate(document()), sizes); | |
| 657 float effectiveSize = parser.length(); | |
| 658 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de
vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src
setAttr), &document()); | |
| 659 setBestFitURLAndDPRFromImageCandidate(candidate); | 657 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 660 } | 658 } |
| 661 if (m_intrinsicSizingViewportDependant && !m_listener) { | 659 if (m_intrinsicSizingViewportDependant && !m_listener) { |
| 662 m_listener = ViewportChangeListener::create(this); | 660 m_listener = ViewportChangeListener::create(this); |
| 663 document().mediaQueryMatcher().addViewportListener(m_listener); | 661 document().mediaQueryMatcher().addViewportListener(m_listener); |
| 664 } | 662 } |
| 665 imageLoader().updateFromElement(behavior); | 663 imageLoader().updateFromElement(behavior); |
| 666 | 664 |
| 667 if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSo
urceURL().isEmpty())) | 665 if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSo
urceURL().isEmpty())) |
| 668 ensurePrimaryContent(); | 666 ensurePrimaryContent(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 ensureClosedShadowRoot(); | 724 ensureClosedShadowRoot(); |
| 727 } | 725 } |
| 728 | 726 |
| 729 bool HTMLImageElement::isOpaque() const | 727 bool HTMLImageElement::isOpaque() const |
| 730 { | 728 { |
| 731 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 729 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
| 732 return image && image->currentFrameKnownToBeOpaque(); | 730 return image && image->currentFrameKnownToBeOpaque(); |
| 733 } | 731 } |
| 734 | 732 |
| 735 } | 733 } |
| OLD | NEW |