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 16 matching lines...) Expand all Loading... |
27 #include "core/CSSPropertyNames.h" | 27 #include "core/CSSPropertyNames.h" |
28 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
29 #include "core/MediaTypeNames.h" | 29 #include "core/MediaTypeNames.h" |
30 #include "core/css/MediaQueryMatcher.h" | 30 #include "core/css/MediaQueryMatcher.h" |
31 #include "core/css/MediaValuesDynamic.h" | 31 #include "core/css/MediaValuesDynamic.h" |
32 #include "core/css/parser/SizesAttributeParser.h" | 32 #include "core/css/parser/SizesAttributeParser.h" |
33 #include "core/dom/Attribute.h" | 33 #include "core/dom/Attribute.h" |
34 #include "core/dom/NodeTraversal.h" | 34 #include "core/dom/NodeTraversal.h" |
35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
36 #include "core/fetch/ImageResource.h" | 36 #include "core/fetch/ImageResource.h" |
| 37 #include "core/frame/ImageBitmap.h" |
37 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
38 #include "core/html/HTMLAnchorElement.h" | 39 #include "core/html/HTMLAnchorElement.h" |
39 #include "core/html/HTMLCanvasElement.h" | 40 #include "core/html/HTMLCanvasElement.h" |
40 #include "core/html/HTMLFormElement.h" | 41 #include "core/html/HTMLFormElement.h" |
41 #include "core/html/HTMLImageFallbackHelper.h" | 42 #include "core/html/HTMLImageFallbackHelper.h" |
42 #include "core/html/HTMLSourceElement.h" | 43 #include "core/html/HTMLSourceElement.h" |
43 #include "core/html/parser/HTMLParserIdioms.h" | 44 #include "core/html/parser/HTMLParserIdioms.h" |
44 #include "core/html/parser/HTMLSrcsetParser.h" | 45 #include "core/html/parser/HTMLSrcsetParser.h" |
45 #include "core/inspector/ConsoleMessage.h" | 46 #include "core/inspector/ConsoleMessage.h" |
46 #include "core/layout/LayoutBlockFlow.h" | 47 #include "core/layout/LayoutBlockFlow.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 // If it doesn't exist, we just return the default. | 670 // If it doesn't exist, we just return the default. |
670 sourceSizeValue(element, document(), value); | 671 sourceSizeValue(element, document(), value); |
671 return value; | 672 return value; |
672 } | 673 } |
673 | 674 |
674 void HTMLImageElement::forceReload() const | 675 void HTMLImageElement::forceReload() const |
675 { | 676 { |
676 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP
olicy); | 677 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP
olicy); |
677 } | 678 } |
678 | 679 |
| 680 ScriptPromise HTMLImageElement::createImageBitmap(ScriptState* scriptState, Even
tTarget& eventTarget, int sx, int sy, int sw, int sh, ExceptionState& exceptionS
tate) |
| 681 { |
| 682 ASSERT(eventTarget.toDOMWindow()); |
| 683 if (!cachedImage()) { |
| 684 exceptionState.throwDOMException(InvalidStateError, "No image can be ret
rieved from the provided element."); |
| 685 return ScriptPromise(); |
| 686 } |
| 687 if (cachedImage()->image()->isSVGImage()) { |
| 688 exceptionState.throwDOMException(InvalidStateError, "The image element c
ontains an SVG image, which is unsupported."); |
| 689 return ScriptPromise(); |
| 690 } |
| 691 if (!sw || !sh) { |
| 692 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); |
| 693 return ScriptPromise(); |
| 694 } |
| 695 if (!cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) { |
| 696 exceptionState.throwSecurityError("The source image contains image data
from multiple origins."); |
| 697 return ScriptPromise(); |
| 698 } |
| 699 Document* document = eventTarget.toDOMWindow()->document(); |
| 700 if (!cachedImage()->passesAccessControlCheck(document->securityOrigin()) &&
document->securityOrigin()->taintsCanvas(src())) { |
| 701 exceptionState.throwSecurityError("Cross-origin access to the source ima
ge is denied."); |
| 702 return ScriptPromise(); |
| 703 } |
| 704 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh))); |
| 705 } |
| 706 |
679 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) | 707 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) |
680 { | 708 { |
681 if (!document().isActive()) | 709 if (!document().isActive()) |
682 return; | 710 return; |
683 | 711 |
684 bool foundURL = false; | 712 bool foundURL = false; |
685 ImageCandidate candidate = findBestFitImageFromPictureParent(); | 713 ImageCandidate candidate = findBestFitImageFromPictureParent(); |
686 if (!candidate.isEmpty()) { | 714 if (!candidate.isEmpty()) { |
687 setBestFitURLAndDPRFromImageCandidate(candidate); | 715 setBestFitURLAndDPRFromImageCandidate(candidate); |
688 foundURL = true; | 716 foundURL = true; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 796 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
769 ensureUserAgentShadowRoot(); | 797 ensureUserAgentShadowRoot(); |
770 } | 798 } |
771 | 799 |
772 bool HTMLImageElement::isOpaque() const | 800 bool HTMLImageElement::isOpaque() const |
773 { | 801 { |
774 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 802 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
775 return image && image->currentFrameKnownToBeOpaque(); | 803 return image && image->currentFrameKnownToBeOpaque(); |
776 } | 804 } |
777 | 805 |
| 806 IntSize HTMLImageElement::bitmapSourceSize() const |
| 807 { |
| 808 ImageResource* image = cachedImage(); |
| 809 if (!image) |
| 810 return IntSize(); |
| 811 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); |
| 812 ASSERT(lSize.fraction().isZero()); |
| 813 return IntSize(lSize.width(), lSize.height()); |
778 } | 814 } |
| 815 |
| 816 } |
OLD | NEW |