OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "core/frame/DOMWindow.h" | 44 #include "core/frame/DOMWindow.h" |
45 #include "core/frame/ImageBitmap.h" | 45 #include "core/frame/ImageBitmap.h" |
46 #include "core/workers/WorkerGlobalScope.h" | 46 #include "core/workers/WorkerGlobalScope.h" |
47 #include "platform/SharedBuffer.h" | 47 #include "platform/SharedBuffer.h" |
48 #include "platform/graphics/BitmapImage.h" | 48 #include "platform/graphics/BitmapImage.h" |
49 #include "platform/graphics/ImageSource.h" | 49 #include "platform/graphics/ImageSource.h" |
50 #include "platform/graphics/skia/NativeImageSkia.h" | 50 #include "platform/graphics/skia/NativeImageSkia.h" |
51 | 51 |
52 namespace WebCore { | 52 namespace WebCore { |
53 | 53 |
54 using blink::WebMediaPlayer; | |
acolwell GONE FROM CHROMIUM
2014/05/20 16:40:21
nit: no need for a using since you only reference
| |
55 | |
54 static LayoutSize sizeFor(HTMLImageElement* image) | 56 static LayoutSize sizeFor(HTMLImageElement* image) |
55 { | 57 { |
56 if (ImageResource* cachedImage = image->cachedImage()) | 58 if (ImageResource* cachedImage = image->cachedImage()) |
57 return cachedImage->imageSizeForRenderer(image->renderer(), 1.0f); // FI XME: Not sure about this. | 59 return cachedImage->imageSizeForRenderer(image->renderer(), 1.0f); // FI XME: Not sure about this. |
58 return IntSize(); | 60 return IntSize(); |
59 } | 61 } |
60 | 62 |
61 static IntSize sizeFor(HTMLVideoElement* video) | 63 static IntSize sizeFor(HTMLVideoElement* video) |
62 { | 64 { |
63 if (MediaPlayer* player = video->player()) | 65 if (WebMediaPlayer* webMediaPlayer = video->webMediaPlayer()) |
64 return player->naturalSize(); | 66 return webMediaPlayer->naturalSize(); |
65 return IntSize(); | 67 return IntSize(); |
66 } | 68 } |
67 | 69 |
68 static ScriptPromise fulfillImageBitmap(ScriptState* scriptState, PassRefPtrWill BeRawPtr<ImageBitmap> imageBitmap) | 70 static ScriptPromise fulfillImageBitmap(ScriptState* scriptState, PassRefPtrWill BeRawPtr<ImageBitmap> imageBitmap) |
69 { | 71 { |
70 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | 72 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); |
71 ScriptPromise promise = resolver->promise(); | 73 ScriptPromise promise = resolver->promise(); |
72 if (imageBitmap) { | 74 if (imageBitmap) { |
73 resolver->resolve(imageBitmap); | 75 resolver->resolve(imageBitmap); |
74 } else { | 76 } else { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 return ScriptPromise(); | 138 return ScriptPromise(); |
137 } | 139 } |
138 if (!sw || !sh) { | 140 if (!sw || !sh) { |
139 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); | 141 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); |
140 return ScriptPromise(); | 142 return ScriptPromise(); |
141 } | 143 } |
142 if (!video->hasSingleSecurityOrigin()) { | 144 if (!video->hasSingleSecurityOrigin()) { |
143 exceptionState.throwSecurityError("The source video contains image data from multiple origins."); | 145 exceptionState.throwSecurityError("The source video contains image data from multiple origins."); |
144 return ScriptPromise(); | 146 return ScriptPromise(); |
145 } | 147 } |
146 if (!video->player()->didPassCORSAccessCheck() && eventTarget.toDOMWindow()- >document()->securityOrigin()->taintsCanvas(video->currentSrc())) { | 148 if (!(video->webMediaPlayer() && video->webMediaPlayer()->didPassCORSAccessC heck()) |
149 && eventTarget.toDOMWindow()->document()->securityOrigin()->taintsCanvas (video->currentSrc())) { | |
147 exceptionState.throwSecurityError("Cross-origin access to the source vid eo is denied."); | 150 exceptionState.throwSecurityError("Cross-origin access to the source vid eo is denied."); |
148 return ScriptPromise(); | 151 return ScriptPromise(); |
149 } | 152 } |
150 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 153 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
151 return fulfillImageBitmap(scriptState, ImageBitmap::create(video, IntRect(sx , sy, sw, sh))); | 154 return fulfillImageBitmap(scriptState, ImageBitmap::create(video, IntRect(sx , sy, sw, sh))); |
152 } | 155 } |
153 | 156 |
154 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, CanvasRenderingContext2D* context, ExceptionState& exc eptionState) | 157 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, CanvasRenderingContext2D* context, ExceptionState& exc eptionState) |
155 { | 158 { |
156 return createImageBitmap(scriptState, eventTarget, context->canvas(), except ionState); | 159 return createImageBitmap(scriptState, eventTarget, context->canvas(), except ionState); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 { | 336 { |
334 rejectPromise(); | 337 rejectPromise(); |
335 } | 338 } |
336 | 339 |
337 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor) | 340 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor) |
338 { | 341 { |
339 visitor->trace(m_factory); | 342 visitor->trace(m_factory); |
340 } | 343 } |
341 | 344 |
342 } // namespace WebCore | 345 } // namespace WebCore |
OLD | NEW |