| 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 | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights |
| 5 * reserved. | 5 * reserved. |
| 6 * Copyright (C) 2010 Google Inc. All rights reserved. | 6 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 // value. If it doesn't exist, we just return the default. | 677 // value. If it doesn't exist, we just return the default. |
| 678 sourceSizeValue(element, document(), value); | 678 sourceSizeValue(element, document(), value); |
| 679 return value; | 679 return value; |
| 680 } | 680 } |
| 681 | 681 |
| 682 void HTMLImageElement::forceReload() const { | 682 void HTMLImageElement::forceReload() const { |
| 683 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, | 683 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, |
| 684 m_referrerPolicy); | 684 m_referrerPolicy); |
| 685 } | 685 } |
| 686 | 686 |
| 687 ScriptPromise HTMLImageElement::createImageBitmap( | |
| 688 ScriptState* scriptState, | |
| 689 EventTarget& eventTarget, | |
| 690 Optional<IntRect> cropRect, | |
| 691 const ImageBitmapOptions& options, | |
| 692 ExceptionState& exceptionState) { | |
| 693 DCHECK(eventTarget.toLocalDOMWindow()); | |
| 694 if ((cropRect && | |
| 695 !ImageBitmap::isSourceSizeValid(cropRect->width(), cropRect->height(), | |
| 696 exceptionState)) || | |
| 697 !ImageBitmap::isSourceSizeValid(bitmapSourceSize().width(), | |
| 698 bitmapSourceSize().height(), | |
| 699 exceptionState)) | |
| 700 return ScriptPromise(); | |
| 701 if (!ImageBitmap::isResizeOptionValid(options, exceptionState)) | |
| 702 return ScriptPromise(); | |
| 703 return ImageBitmapSource::fulfillImageBitmap( | |
| 704 scriptState, | |
| 705 ImageBitmap::create(this, cropRect, | |
| 706 eventTarget.toLocalDOMWindow()->document(), options)); | |
| 707 } | |
| 708 | |
| 709 void HTMLImageElement::selectSourceURL( | 687 void HTMLImageElement::selectSourceURL( |
| 710 ImageLoader::UpdateFromElementBehavior behavior) { | 688 ImageLoader::UpdateFromElementBehavior behavior) { |
| 711 if (!document().isActive()) | 689 if (!document().isActive()) |
| 712 return; | 690 return; |
| 713 | 691 |
| 714 bool foundURL = false; | 692 bool foundURL = false; |
| 715 ImageCandidate candidate = findBestFitImageFromPictureParent(); | 693 ImageCandidate candidate = findBestFitImageFromPictureParent(); |
| 716 if (!candidate.isEmpty()) { | 694 if (!candidate.isEmpty()) { |
| 717 setBestFitURLAndDPRFromImageCandidate(candidate); | 695 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 718 foundURL = true; | 696 foundURL = true; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 return originalStyleForLayoutObject(); | 797 return originalStyleForLayoutObject(); |
| 820 case LayoutDisposition::FallbackContent: | 798 case LayoutDisposition::FallbackContent: |
| 821 return HTMLImageFallbackHelper::customStyleForAltText( | 799 return HTMLImageFallbackHelper::customStyleForAltText( |
| 822 *this, ComputedStyle::clone(*originalStyleForLayoutObject())); | 800 *this, ComputedStyle::clone(*originalStyleForLayoutObject())); |
| 823 default: | 801 default: |
| 824 NOTREACHED(); | 802 NOTREACHED(); |
| 825 return nullptr; | 803 return nullptr; |
| 826 } | 804 } |
| 827 } | 805 } |
| 828 | 806 |
| 829 IntSize HTMLImageElement::bitmapSourceSize() const { | |
| 830 ImageResourceContent* image = cachedImage(); | |
| 831 if (!image) | |
| 832 return IntSize(); | |
| 833 LayoutSize lSize = image->imageSize( | |
| 834 LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); | |
| 835 DCHECK(lSize.fraction().isZero()); | |
| 836 return IntSize(lSize.width().toInt(), lSize.height().toInt()); | |
| 837 } | |
| 838 | |
| 839 void HTMLImageElement::associateWith(HTMLFormElement* form) { | 807 void HTMLImageElement::associateWith(HTMLFormElement* form) { |
| 840 if (form && form->isConnected()) { | 808 if (form && form->isConnected()) { |
| 841 m_form = form; | 809 m_form = form; |
| 842 m_formWasSetByParser = true; | 810 m_formWasSetByParser = true; |
| 843 m_form->associate(*this); | 811 m_form->associate(*this); |
| 844 m_form->didAssociateByParser(); | 812 m_form->didAssociateByParser(); |
| 845 } | 813 } |
| 846 }; | 814 }; |
| 847 | 815 |
| 848 FloatSize HTMLImageElement::sourceDefaultObjectSize() { | 816 FloatSize HTMLImageElement::sourceDefaultObjectSize() { |
| 849 return FloatSize(width(), height()); | 817 return FloatSize(width(), height()); |
| 850 } | 818 } |
| 851 | 819 |
| 852 } // namespace blink | 820 } // namespace blink |
| OLD | NEW |