OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010 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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "core/layout/LayoutVideo.h" | 26 #include "core/layout/LayoutVideo.h" |
27 | 27 |
28 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/html/HTMLVideoElement.h" | 30 #include "core/html/HTMLVideoElement.h" |
31 #include "core/layout/LayoutBlockFlow.h" | |
32 #include "core/layout/LayoutFullScreen.h" | |
33 #include "core/paint/VideoPainter.h" | 31 #include "core/paint/VideoPainter.h" |
34 #include "public/platform/WebLayer.h" | 32 #include "public/platform/WebLayer.h" |
35 | 33 |
36 namespace blink { | 34 namespace blink { |
37 | 35 |
38 using namespace HTMLNames; | 36 using namespace HTMLNames; |
39 | 37 |
40 LayoutVideo::LayoutVideo(HTMLVideoElement* video) : LayoutMedia(video) { | 38 LayoutVideo::LayoutVideo(HTMLVideoElement* video) : LayoutMedia(video) { |
41 setIntrinsicSize(calculateIntrinsicSize()); | 39 setIntrinsicSize(calculateIntrinsicSize()); |
42 } | 40 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 184 } |
187 // If we are displaying the poster image no pre-rounding is needed, but the | 185 // If we are displaying the poster image no pre-rounding is needed, but the |
188 // size of the image should be used for fitting instead. | 186 // size of the image should be used for fitting instead. |
189 return computeObjectFit(&m_cachedImageSize); | 187 return computeObjectFit(&m_cachedImageSize); |
190 } | 188 } |
191 | 189 |
192 bool LayoutVideo::supportsAcceleratedRendering() const { | 190 bool LayoutVideo::supportsAcceleratedRendering() const { |
193 return !!mediaElement()->platformLayer(); | 191 return !!mediaElement()->platformLayer(); |
194 } | 192 } |
195 | 193 |
196 static const LayoutBlock* layoutObjectPlaceholder( | |
197 const LayoutObject* layoutObject) { | |
198 LayoutObject* parent = layoutObject->parent(); | |
199 if (!parent) | |
200 return nullptr; | |
201 | |
202 LayoutFullScreen* fullScreen = | |
203 parent->isLayoutFullScreen() ? toLayoutFullScreen(parent) : 0; | |
204 if (!fullScreen) | |
205 return nullptr; | |
206 | |
207 return fullScreen->placeholder(); | |
208 } | |
209 | |
210 LayoutUnit LayoutVideo::offsetLeft(const Element* parent) const { | |
211 if (const LayoutBlock* block = layoutObjectPlaceholder(this)) | |
212 return block->offsetLeft(parent); | |
213 return LayoutMedia::offsetLeft(parent); | |
214 } | |
215 | |
216 LayoutUnit LayoutVideo::offsetTop(const Element* parent) const { | |
217 if (const LayoutBlock* block = layoutObjectPlaceholder(this)) | |
218 return block->offsetTop(parent); | |
219 return LayoutMedia::offsetTop(parent); | |
220 } | |
221 | |
222 LayoutUnit LayoutVideo::offsetWidth() const { | |
223 if (const LayoutBlock* block = layoutObjectPlaceholder(this)) | |
224 return block->offsetWidth(); | |
225 return LayoutMedia::offsetWidth(); | |
226 } | |
227 | |
228 LayoutUnit LayoutVideo::offsetHeight() const { | |
229 if (const LayoutBlock* block = layoutObjectPlaceholder(this)) | |
230 return block->offsetHeight(); | |
231 return LayoutMedia::offsetHeight(); | |
232 } | |
233 | |
234 CompositingReasons LayoutVideo::additionalCompositingReasons() const { | 194 CompositingReasons LayoutVideo::additionalCompositingReasons() const { |
235 HTMLMediaElement* element = toHTMLMediaElement(node()); | 195 HTMLMediaElement* element = toHTMLMediaElement(node()); |
236 if (element->isFullscreen() && element->usesOverlayFullscreenVideo()) | 196 if (element->isFullscreen() && element->usesOverlayFullscreenVideo()) |
237 return CompositingReasonVideo; | 197 return CompositingReasonVideo; |
238 | 198 |
239 if (shouldDisplayVideo() && supportsAcceleratedRendering()) | 199 if (shouldDisplayVideo() && supportsAcceleratedRendering()) |
240 return CompositingReasonVideo; | 200 return CompositingReasonVideo; |
241 | 201 |
242 return CompositingReasonNone; | 202 return CompositingReasonNone; |
243 } | 203 } |
244 | 204 |
245 } // namespace blink | 205 } // namespace blink |
OLD | NEW |