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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 MediaPlayer* player = mediaElement()->player(); | 100 MediaPlayer* player = mediaElement()->player(); |
101 if (player && video->readyState() >= HTMLVideoElement::HAVE_METADATA) { | 101 if (player && video->readyState() >= HTMLVideoElement::HAVE_METADATA) { |
102 LayoutSize size = player->naturalSize(); | 102 LayoutSize size = player->naturalSize(); |
103 if (!size.isEmpty()) | 103 if (!size.isEmpty()) |
104 return size; | 104 return size; |
105 } | 105 } |
106 | 106 |
107 if (video->shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && !im
ageResource()->errorOccurred()) | 107 if (video->shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && !im
ageResource()->errorOccurred()) |
108 return m_cachedImageSize; | 108 return m_cachedImageSize; |
109 | 109 |
110 // When the natural size of the video is unavailable, we use the provided | |
111 // width and height attributes of the video element as the intrinsic size un
til | |
112 // better values become available. | |
113 if (video->hasAttribute(widthAttr) && video->hasAttribute(heightAttr)) | |
114 return LayoutSize(video->width(), video->height()); | |
115 | |
116 // <video> in standalone media documents should not use the default 300x150 | 110 // <video> in standalone media documents should not use the default 300x150 |
117 // size since they also have audio-only files. By setting the intrinsic | 111 // size since they also have audio-only files. By setting the intrinsic |
118 // size to 300x1 the video will resize itself in these cases, and audio will | 112 // size to 300x1 the video will resize itself in these cases, and audio will |
119 // have the correct height (it needs to be > 0 for controls to render proper
ly). | 113 // have the correct height (it needs to be > 0 for controls to render proper
ly). |
120 if (video->ownerDocument() && video->ownerDocument()->isMediaDocument()) | 114 if (video->ownerDocument() && video->ownerDocument()->isMediaDocument()) |
121 return LayoutSize(defaultSize().width(), 1); | 115 return LayoutSize(defaultSize().width(), 1); |
122 | 116 |
123 return defaultSize(); | 117 return defaultSize(); |
124 } | 118 } |
125 | 119 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 269 } |
276 | 270 |
277 LayoutUnit RenderVideo::offsetHeight() const | 271 LayoutUnit RenderVideo::offsetHeight() const |
278 { | 272 { |
279 if (const RenderBlock* block = rendererPlaceholder(this)) | 273 if (const RenderBlock* block = rendererPlaceholder(this)) |
280 return block->offsetHeight(); | 274 return block->offsetHeight(); |
281 return RenderMedia::offsetHeight(); | 275 return RenderMedia::offsetHeight(); |
282 } | 276 } |
283 | 277 |
284 } // namespace WebCore | 278 } // namespace WebCore |
OLD | NEW |