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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 static LayoutSize sizeFor(HTMLImageElement* image) | 54 static LayoutSize sizeFor(HTMLImageElement* image) |
55 { | 55 { |
56 if (ImageResource* cachedImage = image->cachedImage()) | 56 if (ImageResource* cachedImage = image->cachedImage()) |
57 return cachedImage->imageSizeForRenderer(image->renderer(), 1.0f); // FI
XME: Not sure about this. | 57 return cachedImage->imageSizeForRenderer(image->renderer(), 1.0f); // FI
XME: Not sure about this. |
58 return IntSize(); | 58 return IntSize(); |
59 } | 59 } |
60 | 60 |
61 static IntSize sizeFor(HTMLVideoElement* video) | 61 static IntSize sizeFor(HTMLVideoElement* video) |
62 { | 62 { |
63 if (MediaPlayer* player = video->player()) | 63 if (blink::WebMediaPlayer* webMediaPlayer = video->webMediaPlayer()) |
64 return player->naturalSize(); | 64 return webMediaPlayer->naturalSize(); |
65 return IntSize(); | 65 return IntSize(); |
66 } | 66 } |
67 | 67 |
68 static ScriptPromise fulfillImageBitmap(ScriptState* scriptState, PassRefPtrWill
BeRawPtr<ImageBitmap> imageBitmap) | 68 static ScriptPromise fulfillImageBitmap(ScriptState* scriptState, PassRefPtrWill
BeRawPtr<ImageBitmap> imageBitmap) |
69 { | 69 { |
70 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 70 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
71 ScriptPromise promise = resolver->promise(); | 71 ScriptPromise promise = resolver->promise(); |
72 if (imageBitmap) { | 72 if (imageBitmap) { |
73 resolver->resolve(imageBitmap); | 73 resolver->resolve(imageBitmap); |
74 } else { | 74 } else { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return ScriptPromise(); | 136 return ScriptPromise(); |
137 } | 137 } |
138 if (!sw || !sh) { | 138 if (!sw || !sh) { |
139 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); | 139 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); |
140 return ScriptPromise(); | 140 return ScriptPromise(); |
141 } | 141 } |
142 if (!video->hasSingleSecurityOrigin()) { | 142 if (!video->hasSingleSecurityOrigin()) { |
143 exceptionState.throwSecurityError("The source video contains image data
from multiple origins."); | 143 exceptionState.throwSecurityError("The source video contains image data
from multiple origins."); |
144 return ScriptPromise(); | 144 return ScriptPromise(); |
145 } | 145 } |
146 if (!video->player()->didPassCORSAccessCheck() && eventTarget.toDOMWindow()-
>document()->securityOrigin()->taintsCanvas(video->currentSrc())) { | 146 if (!(video->webMediaPlayer() && video->webMediaPlayer()->didPassCORSAccessC
heck()) |
| 147 && eventTarget.toDOMWindow()->document()->securityOrigin()->taintsCanvas
(video->currentSrc())) { |
147 exceptionState.throwSecurityError("Cross-origin access to the source vid
eo is denied."); | 148 exceptionState.throwSecurityError("Cross-origin access to the source vid
eo is denied."); |
148 return ScriptPromise(); | 149 return ScriptPromise(); |
149 } | 150 } |
150 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 151 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
151 return fulfillImageBitmap(scriptState, ImageBitmap::create(video, IntRect(sx
, sy, sw, sh))); | 152 return fulfillImageBitmap(scriptState, ImageBitmap::create(video, IntRect(sx
, sy, sw, sh))); |
152 } | 153 } |
153 | 154 |
154 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, CanvasRenderingContext2D* context, ExceptionState& exc
eptionState) | 155 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, CanvasRenderingContext2D* context, ExceptionState& exc
eptionState) |
155 { | 156 { |
156 return createImageBitmap(scriptState, eventTarget, context->canvas(), except
ionState); | 157 return createImageBitmap(scriptState, eventTarget, context->canvas(), except
ionState); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 { | 334 { |
334 rejectPromise(); | 335 rejectPromise(); |
335 } | 336 } |
336 | 337 |
337 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor) | 338 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor) |
338 { | 339 { |
339 visitor->trace(m_factory); | 340 visitor->trace(m_factory); |
340 } | 341 } |
341 | 342 |
342 } // namespace WebCore | 343 } // namespace WebCore |
OLD | NEW |