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

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

Issue 1387743002: Fixed expando-loss.html test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cache ScriptState and use it to wrap m_defaultVertexArrayObject. Created 5 years, 2 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory) 217 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory)
218 { 218 {
219 CanvasRenderingContext::ContextType type = renderingContextFactory->contextT ype(); 219 CanvasRenderingContext::ContextType type = renderingContextFactory->contextT ype();
220 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 220 ASSERT(type < CanvasRenderingContext::ContextTypeCount);
221 ASSERT(!renderingContextFactories()[type]); 221 ASSERT(!renderingContextFactories()[type]);
222 renderingContextFactories()[type] = renderingContextFactory; 222 renderingContextFactories()[type] = renderingContextFactory;
223 } 223 }
224 224
225 ScriptValue HTMLCanvasElement::getContext(ScriptState* scriptState, const String & type, const CanvasContextCreationAttributes& attributes) 225 ScriptValue HTMLCanvasElement::getContext(ScriptState* scriptState, const String & type, const CanvasContextCreationAttributes& attributes)
226 { 226 {
227 CanvasRenderingContext* context = getCanvasRenderingContext(type, attributes ); 227 CanvasRenderingContext* context = getCanvasRenderingContext(scriptState, typ e, attributes);
228 if (!context) { 228 if (!context) {
229 return ScriptValue::createNull(scriptState); 229 return ScriptValue::createNull(scriptState);
230 } 230 }
231 return ScriptValue(scriptState, toV8(context, scriptState->context()->Global (), scriptState->isolate())); 231 return ScriptValue(scriptState, toV8(context, scriptState->context()->Global (), scriptState->isolate()));
232 } 232 }
233 233
234 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes) 234 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(ScriptState * scriptState, const String& type, const CanvasContextCreationAttributes& attrib utes)
235 { 235 {
236 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type); 236 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type);
237 237
238 // Unknown type. 238 // Unknown type.
239 if (contextType == CanvasRenderingContext::ContextTypeCount) 239 if (contextType == CanvasRenderingContext::ContextTypeCount)
240 return nullptr; 240 return nullptr;
241 241
242 // Log the aliased context type used. 242 // Log the aliased context type used.
243 if (!m_context) 243 if (!m_context)
244 Platform::current()->histogramEnumeration("Canvas.ContextType", contextT ype, CanvasRenderingContext::ContextTypeCount); 244 Platform::current()->histogramEnumeration("Canvas.ContextType", contextT ype, CanvasRenderingContext::ContextTypeCount);
245 245
246 contextType = CanvasRenderingContext::resolveContextTypeAliases(contextType) ; 246 contextType = CanvasRenderingContext::resolveContextTypeAliases(contextType) ;
247 247
248 CanvasRenderingContextFactory* factory = getRenderingContextFactory(contextT ype); 248 CanvasRenderingContextFactory* factory = getRenderingContextFactory(contextT ype);
249 if (!factory) 249 if (!factory)
250 return nullptr; 250 return nullptr;
251 251
252 // FIXME - The code depends on the context not going away once created, to p revent JS from 252 // FIXME - The code depends on the context not going away once created, to p revent JS from
253 // seeing a dangling pointer. So for now we will disallow the context from b eing changed 253 // seeing a dangling pointer. So for now we will disallow the context from b eing changed
254 // once it is created. 254 // once it is created.
255 if (m_context) { 255 if (m_context) {
256 if (m_context->contextType() == contextType) 256 if (m_context->contextType() == contextType)
257 return m_context.get(); 257 return m_context.get();
258 258
259 factory->onError(this, "Canvas has an existing context of a different ty pe"); 259 factory->onError(this, "Canvas has an existing context of a different ty pe");
260 return nullptr; 260 return nullptr;
261 } 261 }
262 262
263 m_context = factory->create(this, attributes, document()); 263 m_context = factory->create(this, scriptState, attributes, document());
264 if (!m_context) 264 if (!m_context)
265 return nullptr; 265 return nullptr;
266 266
267 if (m_context->is3d()) { 267 if (m_context->is3d()) {
268 const ComputedStyle* style = ensureComputedStyle(); 268 const ComputedStyle* style = ensureComputedStyle();
269 if (style) 269 if (style)
270 m_context->setFilterQuality(style->imageRendering() == ImageRenderin gPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality); 270 m_context->setFilterQuality(style->imageRendering() == ImageRenderin gPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality);
271 updateExternallyAllocatedMemory(); 271 updateExternallyAllocatedMemory();
272 } 272 }
273 setNeedsCompositingUpdate(); 273 setNeedsCompositingUpdate();
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 { 979 {
980 return FloatSize(width(), height()); 980 return FloatSize(width(), height());
981 } 981 }
982 982
983 bool HTMLCanvasElement::isOpaque() const 983 bool HTMLCanvasElement::isOpaque() const
984 { 984 {
985 return m_context && !m_context->hasAlpha(); 985 return m_context && !m_context->hasAlpha();
986 } 986 }
987 987
988 } // blink 988 } // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698