Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "platform/weborigin/SecurityOrigin.h" | 30 #include "platform/weborigin/SecurityOrigin.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement* canvas, Offscr eenCanvas* offscreenCanvas) | 34 CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement* canvas, Offscr eenCanvas* offscreenCanvas) |
| 35 : m_canvas(canvas) | 35 : m_canvas(canvas) |
| 36 , m_offscreenCanvas(offscreenCanvas) | 36 , m_offscreenCanvas(offscreenCanvas) |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void CanvasRenderingContext::dispose() | |
| 41 { | |
| 42 // HTMLCanvasElement and CanvasRenderingContext have a circular reference. | |
| 43 // When the pair is no longer reachable, their destruction order is non- | |
| 44 // deterministic, so the first of the two to be destroyed needs to notify | |
| 45 // the other in order to break the circular reference. This is to avoid | |
| 46 // an error when CanvasRenderingContext2D::didProcessTask() is invoked | |
| 47 // after the HTMLCanvasElement is destroyed. | |
| 48 if (canvas()) | |
| 49 canvas()->detachContext(); | |
|
xlai (Olivia)
2016/06/10 19:28:17
Same as above comment. Maybe add one more line her
Justin Novosad
2016/06/10 19:39:09
Done.
| |
| 50 } | |
| 51 | |
| 40 CanvasRenderingContext::ContextType CanvasRenderingContext::contextTypeFromId(co nst String& id) | 52 CanvasRenderingContext::ContextType CanvasRenderingContext::contextTypeFromId(co nst String& id) |
| 41 { | 53 { |
| 42 if (id == "2d") | 54 if (id == "2d") |
| 43 return Context2d; | 55 return Context2d; |
| 44 if (id == "experimental-webgl") | 56 if (id == "experimental-webgl") |
| 45 return ContextExperimentalWebgl; | 57 return ContextExperimentalWebgl; |
| 46 if (id == "webgl") | 58 if (id == "webgl") |
| 47 return ContextWebgl; | 59 return ContextWebgl; |
| 48 if (id == "webgl2") | 60 if (id == "webgl2") |
| 49 return ContextWebgl2; | 61 return ContextWebgl2; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 65 const KURL& sourceURL = imageSource->sourceURL(); | 77 const KURL& sourceURL = imageSource->sourceURL(); |
| 66 bool hasURL = (sourceURL.isValid() && !sourceURL.isAboutBlankURL()); | 78 bool hasURL = (sourceURL.isValid() && !sourceURL.isAboutBlankURL()); |
| 67 | 79 |
| 68 if (hasURL) { | 80 if (hasURL) { |
| 69 if (sourceURL.protocolIsData() || m_cleanURLs.contains(sourceURL.getStri ng())) | 81 if (sourceURL.protocolIsData() || m_cleanURLs.contains(sourceURL.getStri ng())) |
| 70 return false; | 82 return false; |
| 71 if (m_dirtyURLs.contains(sourceURL.getString())) | 83 if (m_dirtyURLs.contains(sourceURL.getString())) |
| 72 return true; | 84 return true; |
| 73 } | 85 } |
| 74 | 86 |
| 75 ASSERT(!canvas() == !!destinationSecurityOrigin); // Must have one or the ot her | 87 DCHECK_EQ(!canvas(), !!destinationSecurityOrigin); // Must have one or the o ther |
| 76 bool taintOrigin = imageSource->wouldTaintOrigin(destinationSecurityOrigin ? destinationSecurityOrigin : canvas()->getSecurityOrigin()); | 88 bool taintOrigin = imageSource->wouldTaintOrigin(destinationSecurityOrigin ? destinationSecurityOrigin : canvas()->getSecurityOrigin()); |
| 77 | 89 |
| 78 if (hasURL) { | 90 if (hasURL) { |
| 79 if (taintOrigin) | 91 if (taintOrigin) |
| 80 m_dirtyURLs.add(sourceURL.getString()); | 92 m_dirtyURLs.add(sourceURL.getString()); |
| 81 else | 93 else |
| 82 m_cleanURLs.add(sourceURL.getString()); | 94 m_cleanURLs.add(sourceURL.getString()); |
| 83 } | 95 } |
| 84 return taintOrigin; | 96 return taintOrigin; |
| 85 } | 97 } |
| 86 | 98 |
| 87 DEFINE_TRACE(CanvasRenderingContext) | 99 DEFINE_TRACE(CanvasRenderingContext) |
| 88 { | 100 { |
| 89 visitor->trace(m_canvas); | 101 visitor->trace(m_canvas); |
| 90 visitor->trace(m_offscreenCanvas); | 102 visitor->trace(m_offscreenCanvas); |
| 91 } | 103 } |
| 92 | 104 |
| 93 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |