OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/html/HTMLCanvasElement.h" | 29 #include "core/html/HTMLCanvasElement.h" |
30 | 30 |
31 #include "bindings/core/v8/ExceptionMessages.h" | 31 #include "bindings/core/v8/ExceptionMessages.h" |
32 #include "bindings/core/v8/ExceptionState.h" | 32 #include "bindings/core/v8/ExceptionState.h" |
33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
34 #include "core/HTMLNames.h" | 34 #include "core/HTMLNames.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
37 #include "core/fileapi/File.h" | 37 #include "core/fileapi/File.h" |
| 38 #include "core/frame/ImageBitmap.h" |
38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
40 #include "core/html/ImageData.h" | 41 #include "core/html/ImageData.h" |
41 #include "core/html/canvas/CanvasAsyncBlobCreator.h" | 42 #include "core/html/canvas/CanvasAsyncBlobCreator.h" |
42 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 43 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
43 #include "core/html/canvas/CanvasFontCache.h" | 44 #include "core/html/canvas/CanvasFontCache.h" |
44 #include "core/html/canvas/CanvasRenderingContext.h" | 45 #include "core/html/canvas/CanvasRenderingContext.h" |
45 #include "core/html/canvas/CanvasRenderingContextFactory.h" | 46 #include "core/html/canvas/CanvasRenderingContextFactory.h" |
46 #include "core/layout/LayoutHTMLCanvas.h" | 47 #include "core/layout/LayoutHTMLCanvas.h" |
47 #include "core/paint/PaintLayer.h" | 48 #include "core/paint/PaintLayer.h" |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 927 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
927 { | 928 { |
928 return !originClean(); | 929 return !originClean(); |
929 } | 930 } |
930 | 931 |
931 FloatSize HTMLCanvasElement::elementSize() const | 932 FloatSize HTMLCanvasElement::elementSize() const |
932 { | 933 { |
933 return FloatSize(width(), height()); | 934 return FloatSize(width(), height()); |
934 } | 935 } |
935 | 936 |
| 937 IntSize HTMLCanvasElement::bitmapSourceSize() const |
| 938 { |
| 939 return IntSize(width(), height()); |
| 940 } |
| 941 |
| 942 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve
ntTarget& eventTarget, int sx, int sy, int sw, int sh, ExceptionState& exception
State) |
| 943 { |
| 944 ASSERT(eventTarget.toDOMWindow()); |
| 945 if (!originClean()) { |
| 946 exceptionState.throwSecurityError("The canvas element provided is tainte
d with cross-origin data."); |
| 947 return ScriptPromise(); |
| 948 } |
| 949 if (!sw || !sh) { |
| 950 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); |
| 951 return ScriptPromise(); |
| 952 } |
| 953 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh)) : nullptr); |
| 954 } |
| 955 |
936 bool HTMLCanvasElement::isOpaque() const | 956 bool HTMLCanvasElement::isOpaque() const |
937 { | 957 { |
938 return m_context && !m_context->hasAlpha(); | 958 return m_context && !m_context->hasAlpha(); |
939 } | 959 } |
940 | 960 |
941 } // blink | 961 } // blink |
OLD | NEW |