| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // value. If it doesn't exist, we just return the default. | 681 // value. If it doesn't exist, we just return the default. |
| 682 SourceSizeValue(element, GetDocument(), value); | 682 SourceSizeValue(element, GetDocument(), value); |
| 683 return value; | 683 return value; |
| 684 } | 684 } |
| 685 | 685 |
| 686 void HTMLImageElement::ForceReload() const { | 686 void HTMLImageElement::ForceReload() const { |
| 687 GetImageLoader().UpdateFromElement(ImageLoader::kUpdateForcedReload, | 687 GetImageLoader().UpdateFromElement(ImageLoader::kUpdateForcedReload, |
| 688 referrer_policy_); | 688 referrer_policy_); |
| 689 } | 689 } |
| 690 | 690 |
| 691 ScriptPromise HTMLImageElement::CreateImageBitmap( |
| 692 ScriptState* script_state, |
| 693 EventTarget& event_target, |
| 694 Optional<IntRect> crop_rect, |
| 695 const ImageBitmapOptions& options, |
| 696 ExceptionState& exception_state) { |
| 697 DCHECK(event_target.ToLocalDOMWindow()); |
| 698 if ((crop_rect && |
| 699 !ImageBitmap::IsSourceSizeValid(crop_rect->Width(), crop_rect->Height(), |
| 700 exception_state)) || |
| 701 !ImageBitmap::IsSourceSizeValid(BitmapSourceSize().Width(), |
| 702 BitmapSourceSize().Height(), |
| 703 exception_state)) |
| 704 return ScriptPromise(); |
| 705 if (!ImageBitmap::IsResizeOptionValid(options, exception_state)) |
| 706 return ScriptPromise(); |
| 707 return ImageBitmapSource::FulfillImageBitmap( |
| 708 script_state, ImageBitmap::Create( |
| 709 this, crop_rect, |
| 710 event_target.ToLocalDOMWindow()->document(), options)); |
| 711 } |
| 712 |
| 691 void HTMLImageElement::SelectSourceURL( | 713 void HTMLImageElement::SelectSourceURL( |
| 692 ImageLoader::UpdateFromElementBehavior behavior) { | 714 ImageLoader::UpdateFromElementBehavior behavior) { |
| 693 if (!GetDocument().IsActive()) | 715 if (!GetDocument().IsActive()) |
| 694 return; | 716 return; |
| 695 | 717 |
| 696 bool found_url = false; | 718 bool found_url = false; |
| 697 ImageCandidate candidate = FindBestFitImageFromPictureParent(); | 719 ImageCandidate candidate = FindBestFitImageFromPictureParent(); |
| 698 if (!candidate.IsEmpty()) { | 720 if (!candidate.IsEmpty()) { |
| 699 SetBestFitURLAndDPRFromImageCandidate(candidate); | 721 SetBestFitURLAndDPRFromImageCandidate(candidate); |
| 700 found_url = true; | 722 found_url = true; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 return OriginalStyleForLayoutObject(); | 826 return OriginalStyleForLayoutObject(); |
| 805 case LayoutDisposition::kFallbackContent: | 827 case LayoutDisposition::kFallbackContent: |
| 806 return HTMLImageFallbackHelper::CustomStyleForAltText( | 828 return HTMLImageFallbackHelper::CustomStyleForAltText( |
| 807 *this, ComputedStyle::Clone(*OriginalStyleForLayoutObject())); | 829 *this, ComputedStyle::Clone(*OriginalStyleForLayoutObject())); |
| 808 default: | 830 default: |
| 809 NOTREACHED(); | 831 NOTREACHED(); |
| 810 return nullptr; | 832 return nullptr; |
| 811 } | 833 } |
| 812 } | 834 } |
| 813 | 835 |
| 836 IntSize HTMLImageElement::BitmapSourceSize() const { |
| 837 ImageResourceContent* image = CachedImage(); |
| 838 if (!image) |
| 839 return IntSize(); |
| 840 LayoutSize l_size = image->ImageSize( |
| 841 LayoutObject::ShouldRespectImageOrientation(GetLayoutObject()), 1.0f); |
| 842 DCHECK(l_size.Fraction().IsZero()); |
| 843 return IntSize(l_size.Width().ToInt(), l_size.Height().ToInt()); |
| 844 } |
| 845 |
| 814 void HTMLImageElement::AssociateWith(HTMLFormElement* form) { | 846 void HTMLImageElement::AssociateWith(HTMLFormElement* form) { |
| 815 if (form && form->isConnected()) { | 847 if (form && form->isConnected()) { |
| 816 form_ = form; | 848 form_ = form; |
| 817 form_was_set_by_parser_ = true; | 849 form_was_set_by_parser_ = true; |
| 818 form_->Associate(*this); | 850 form_->Associate(*this); |
| 819 form_->DidAssociateByParser(); | 851 form_->DidAssociateByParser(); |
| 820 } | 852 } |
| 821 }; | 853 }; |
| 822 | 854 |
| 823 FloatSize HTMLImageElement::SourceDefaultObjectSize() { | 855 FloatSize HTMLImageElement::SourceDefaultObjectSize() { |
| 824 return FloatSize(width(), height()); | 856 return FloatSize(width(), height()); |
| 825 } | 857 } |
| 826 | 858 |
| 827 } // namespace blink | 859 } // namespace blink |
| OLD | NEW |