Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 1761003003: Use a union typdef for the return type of canvas.getContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final touches Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory) 203 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory)
204 { 204 {
205 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType(); 205 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType();
206 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 206 ASSERT(type < CanvasRenderingContext::ContextTypeCount);
207 ASSERT(!renderingContextFactories()[type]); 207 ASSERT(!renderingContextFactories()[type]);
208 renderingContextFactories()[type] = renderingContextFactory; 208 renderingContextFactories()[type] = renderingContextFactory;
209 } 209 }
210 210
211 ScriptValue HTMLCanvasElement::getContext(ScriptState* scriptState, const String & type, const CanvasContextCreationAttributes& attributes)
212 {
213 CanvasRenderingContext* context = getCanvasRenderingContext(type, attributes );
214 if (!context) {
215 return ScriptValue::createNull(scriptState);
216 }
217 return ScriptValue(scriptState, toV8(context, scriptState->context()->Global (), scriptState->isolate()));
218 }
219
220 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes) 211 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes)
221 { 212 {
222 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type); 213 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type);
223 214
224 // Unknown type. 215 // Unknown type.
225 if (contextType == CanvasRenderingContext::ContextTypeCount) 216 if (contextType == CanvasRenderingContext::ContextTypeCount)
226 return nullptr; 217 return nullptr;
227 218
228 // Log the aliased context type used. 219 // Log the aliased context type used.
229 if (!m_context) { 220 if (!m_context) {
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 || element.hasTagName(HTMLNames::tfootTag) 1073 || element.hasTagName(HTMLNames::tfootTag)
1083 || element.hasTagName(HTMLNames::trTag) 1074 || element.hasTagName(HTMLNames::trTag)
1084 || element.hasTagName(HTMLNames::tdTag) 1075 || element.hasTagName(HTMLNames::tdTag)
1085 || element.hasTagName(HTMLNames::thTag)) 1076 || element.hasTagName(HTMLNames::thTag))
1086 return true; 1077 return true;
1087 1078
1088 return false; 1079 return false;
1089 } 1080 }
1090 1081
1091 } // namespace blink 1082 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | third_party/WebKit/Source/core/html/HTMLCanvasElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698