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, ImageBitmapSource* bitmapSource, int sx, int sy, int sw, i nt sh, ExceptionState& exceptionState) | |
681 { | |
682 ASSERT(eventTarget.toDOMWindow()); | |
683 HTMLImageElement* image = static_cast<HTMLImageElement*>(bitmapSource); | |
684 if (!image->cachedImage()) { | |
685 exceptionState.throwDOMException(InvalidStateError, "No image can be ret rieved from the provided element."); | |
686 return ScriptPromise(); | |
687 } | |
688 if (image->cachedImage()->image()->isSVGImage()) { | |
689 exceptionState.throwDOMException(InvalidStateError, "The image element c ontains an SVG image, which is unsupported."); | |
690 return ScriptPromise(); | |
691 } | |
692 if (!sw || !sh) { | |
693 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); | |
694 return ScriptPromise(); | |
695 } | |
696 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) { | |
697 exceptionState.throwSecurityError("The source image contains image data from multiple origins."); | |
698 return ScriptPromise(); | |
699 } | |
700 Document* document = eventTarget.toDOMWindow()->document(); | |
701 if (!image->cachedImage()->passesAccessControlCheck(document->securityOrigin ()) && document->securityOrigin()->taintsCanvas(image->src())) { | |
702 exceptionState.throwSecurityError("Cross-origin access to the source ima ge is denied."); | |
703 return ScriptPromise(); | |
704 } | |
705 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat e(image, IntRect(sx, sy, sw, sh))); | |
706 } | |
707 | |
679 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) | 708 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) |
680 { | 709 { |
681 if (!document().isActive()) | 710 if (!document().isActive()) |
682 return; | 711 return; |
683 | 712 |
684 bool foundURL = false; | 713 bool foundURL = false; |
685 ImageCandidate candidate = findBestFitImageFromPictureParent(); | 714 ImageCandidate candidate = findBestFitImageFromPictureParent(); |
686 if (!candidate.isEmpty()) { | 715 if (!candidate.isEmpty()) { |
687 setBestFitURLAndDPRFromImageCandidate(candidate); | 716 setBestFitURLAndDPRFromImageCandidate(candidate); |
688 foundURL = true; | 717 foundURL = true; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 797 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
769 ensureUserAgentShadowRoot(); | 798 ensureUserAgentShadowRoot(); |
770 } | 799 } |
771 | 800 |
772 bool HTMLImageElement::isOpaque() const | 801 bool HTMLImageElement::isOpaque() const |
773 { | 802 { |
774 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 803 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
775 return image && image->currentFrameKnownToBeOpaque(); | 804 return image && image->currentFrameKnownToBeOpaque(); |
776 } | 805 } |
777 | 806 |
807 IntSize HTMLImageElement::bitmapSourceSize() const | |
808 { | |
809 ImageResource* image = cachedImage(); | |
810 if (!image) | |
811 return IntSize(); | |
812 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f); | |
davve
2015/11/27 11:19:43
Since multiplier is 1 and last argument to imageSi
xidachen
2015/11/27 19:00:25
Done.
| |
813 return IntSize(lSize.width(), lSize.height()); | |
778 } | 814 } |
815 | |
816 } | |
OLD | NEW |