| 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 | |
| 713 void HTMLImageElement::SelectSourceURL( | 691 void HTMLImageElement::SelectSourceURL( |
| 714 ImageLoader::UpdateFromElementBehavior behavior) { | 692 ImageLoader::UpdateFromElementBehavior behavior) { |
| 715 if (!GetDocument().IsActive()) | 693 if (!GetDocument().IsActive()) |
| 716 return; | 694 return; |
| 717 | 695 |
| 718 bool found_url = false; | 696 bool found_url = false; |
| 719 ImageCandidate candidate = FindBestFitImageFromPictureParent(); | 697 ImageCandidate candidate = FindBestFitImageFromPictureParent(); |
| 720 if (!candidate.IsEmpty()) { | 698 if (!candidate.IsEmpty()) { |
| 721 SetBestFitURLAndDPRFromImageCandidate(candidate); | 699 SetBestFitURLAndDPRFromImageCandidate(candidate); |
| 722 found_url = true; | 700 found_url = true; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 return OriginalStyleForLayoutObject(); | 804 return OriginalStyleForLayoutObject(); |
| 827 case LayoutDisposition::kFallbackContent: | 805 case LayoutDisposition::kFallbackContent: |
| 828 return HTMLImageFallbackHelper::CustomStyleForAltText( | 806 return HTMLImageFallbackHelper::CustomStyleForAltText( |
| 829 *this, ComputedStyle::Clone(*OriginalStyleForLayoutObject())); | 807 *this, ComputedStyle::Clone(*OriginalStyleForLayoutObject())); |
| 830 default: | 808 default: |
| 831 NOTREACHED(); | 809 NOTREACHED(); |
| 832 return nullptr; | 810 return nullptr; |
| 833 } | 811 } |
| 834 } | 812 } |
| 835 | 813 |
| 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 | |
| 846 void HTMLImageElement::AssociateWith(HTMLFormElement* form) { | 814 void HTMLImageElement::AssociateWith(HTMLFormElement* form) { |
| 847 if (form && form->isConnected()) { | 815 if (form && form->isConnected()) { |
| 848 form_ = form; | 816 form_ = form; |
| 849 form_was_set_by_parser_ = true; | 817 form_was_set_by_parser_ = true; |
| 850 form_->Associate(*this); | 818 form_->Associate(*this); |
| 851 form_->DidAssociateByParser(); | 819 form_->DidAssociateByParser(); |
| 852 } | 820 } |
| 853 }; | 821 }; |
| 854 | 822 |
| 855 FloatSize HTMLImageElement::SourceDefaultObjectSize() { | 823 FloatSize HTMLImageElement::SourceDefaultObjectSize() { |
| 856 return FloatSize(width(), height()); | 824 return FloatSize(width(), height()); |
| 857 } | 825 } |
| 858 | 826 |
| 859 } // namespace blink | 827 } // namespace blink |
| OLD | NEW |