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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 setIntegralAttribute(widthAttr, value); | 145 setIntegralAttribute(widthAttr, value); |
146 } | 146 } |
147 | 147 |
148 CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
ContextAttributes* attrs) | 148 CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
ContextAttributes* attrs) |
149 { | 149 { |
150 // A Canvas can either be "2D" or "webgl" but never both. If you request a 2
D canvas and the existing | 150 // A Canvas can either be "2D" or "webgl" but never both. If you request a 2
D canvas and the existing |
151 // context is already 2D, just return that. If the existing context is WebGL
, then destroy it | 151 // context is already 2D, just return that. If the existing context is WebGL
, then destroy it |
152 // before creating a new 2D context. Vice versa when requesting a WebGL canv
as. Requesting a | 152 // before creating a new 2D context. Vice versa when requesting a WebGL canv
as. Requesting a |
153 // context with any other type string will destroy any existing context. | 153 // context with any other type string will destroy any existing context. |
154 enum ContextType { | 154 enum ContextType { |
155 Context2d, | 155 // Do not change assigned numbers of existing items: add new features to
the end of the list. |
156 ContextWebkit3d, | 156 Context2d = 0, |
157 ContextExperimentalWebgl, | 157 ContextExperimentalWebgl = 2, |
158 ContextWebgl, | 158 ContextWebgl = 3, |
159 // Only add new items to the end and keep the order of existing items. | |
160 ContextTypeCount, | 159 ContextTypeCount, |
161 }; | 160 }; |
162 | 161 |
163 // FIXME - The code depends on the context not going away once created, to p
revent JS from | 162 // FIXME - The code depends on the context not going away once created, to p
revent JS from |
164 // seeing a dangling pointer. So for now we will disallow the context from b
eing changed | 163 // seeing a dangling pointer. So for now we will disallow the context from b
eing changed |
165 // once it is created. | 164 // once it is created. |
166 if (type == "2d") { | 165 if (type == "2d") { |
167 if (m_context && !m_context->is2d()) | 166 if (m_context && !m_context->is2d()) |
168 return 0; | 167 return 0; |
169 if (!m_context) { | 168 if (!m_context) { |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 { | 739 { |
741 return !originClean(); | 740 return !originClean(); |
742 } | 741 } |
743 | 742 |
744 FloatSize HTMLCanvasElement::sourceSize() const | 743 FloatSize HTMLCanvasElement::sourceSize() const |
745 { | 744 { |
746 return FloatSize(width(), height()); | 745 return FloatSize(width(), height()); |
747 } | 746 } |
748 | 747 |
749 } | 748 } |
OLD | NEW |