Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutVideo.cpp

Issue 2405633002: Reformat comments in core/layout (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 setIntrinsicSize(size); 68 setIntrinsicSize(size);
69 setPreferredLogicalWidthsDirty(); 69 setPreferredLogicalWidthsDirty();
70 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SizeChanged); 70 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SizeChanged);
71 } 71 }
72 72
73 LayoutSize LayoutVideo::calculateIntrinsicSize() { 73 LayoutSize LayoutVideo::calculateIntrinsicSize() {
74 HTMLVideoElement* video = videoElement(); 74 HTMLVideoElement* video = videoElement();
75 75
76 // Spec text from 4.8.6 76 // Spec text from 4.8.6
77 // 77 //
78 // The intrinsic width of a video element's playback area is the intrinsic wid th 78 // The intrinsic width of a video element's playback area is the intrinsic
79 // of the video resource, if that is available; otherwise it is the intrinsic 79 // width of the video resource, if that is available; otherwise it is the
80 // width of the poster frame, if that is available; otherwise it is 300 CSS pi xels. 80 // intrinsic width of the poster frame, if that is available; otherwise it is
81 // 300 CSS pixels.
81 // 82 //
82 // The intrinsic height of a video element's playback area is the intrinsic he ight 83 // The intrinsic height of a video element's playback area is the intrinsic
83 // of the video resource, if that is available; otherwise it is the intrinsic 84 // height of the video resource, if that is available; otherwise it is the
84 // height of the poster frame, if that is available; otherwise it is 150 CSS p ixels. 85 // intrinsic height of the poster frame, if that is available; otherwise it is
86 // 150 CSS pixels.
85 WebMediaPlayer* webMediaPlayer = mediaElement()->webMediaPlayer(); 87 WebMediaPlayer* webMediaPlayer = mediaElement()->webMediaPlayer();
86 if (webMediaPlayer && 88 if (webMediaPlayer &&
87 video->getReadyState() >= HTMLVideoElement::kHaveMetadata) { 89 video->getReadyState() >= HTMLVideoElement::kHaveMetadata) {
88 IntSize size = webMediaPlayer->naturalSize(); 90 IntSize size = webMediaPlayer->naturalSize();
89 if (!size.isEmpty()) 91 if (!size.isEmpty())
90 return LayoutSize(size); 92 return LayoutSize(size);
91 } 93 }
92 94
93 if (video->shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && 95 if (video->shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() &&
94 !imageResource()->errorOccurred()) 96 !imageResource()->errorOccurred())
95 return m_cachedImageSize; 97 return m_cachedImageSize;
96 98
97 // <video> in standalone media documents should not use the default 300x150 99 // <video> in standalone media documents should not use the default 300x150
98 // size since they also have audio-only files. By setting the intrinsic 100 // size since they also have audio-only files. By setting the intrinsic
99 // size to 300x1 the video will resize itself in these cases, and audio will 101 // size to 300x1 the video will resize itself in these cases, and audio will
100 // have the correct height (it needs to be > 0 for controls to layout properly ). 102 // have the correct height (it needs to be > 0 for controls to layout
103 // properly).
101 if (video->ownerDocument() && video->ownerDocument()->isMediaDocument()) 104 if (video->ownerDocument() && video->ownerDocument()->isMediaDocument())
102 return LayoutSize(defaultSize().width(), LayoutUnit(1)); 105 return LayoutSize(defaultSize().width(), LayoutUnit(1));
103 106
104 return defaultSize(); 107 return defaultSize();
105 } 108 }
106 109
107 void LayoutVideo::imageChanged(WrappedImagePtr newImage, const IntRect* rect) { 110 void LayoutVideo::imageChanged(WrappedImagePtr newImage, const IntRect* rect) {
108 LayoutMedia::imageChanged(newImage, rect); 111 LayoutMedia::imageChanged(newImage, rect);
109 112
110 // Cache the image intrinsic size so we can continue to use it to draw the ima ge correctly 113 // Cache the image intrinsic size so we can continue to use it to draw the
111 // even if we know the video intrinsic size but aren't able to draw video fram es yet 114 // image correctly even if we know the video intrinsic size but aren't able to
112 // (we don't want to scale the poster to the video size without keeping aspect ratio). 115 // draw video frames yet (we don't want to scale the poster to the video size
116 // without keeping aspect ratio).
113 if (videoElement()->shouldDisplayPosterImage()) 117 if (videoElement()->shouldDisplayPosterImage())
114 m_cachedImageSize = intrinsicSize(); 118 m_cachedImageSize = intrinsicSize();
115 119
116 // The intrinsic size is now that of the image, but in case we already had the 120 // The intrinsic size is now that of the image, but in case we already had the
117 // intrinsic size of the video we call this here to restore the video size. 121 // intrinsic size of the video we call this here to restore the video size.
118 updateIntrinsicSize(); 122 updateIntrinsicSize();
119 } 123 }
120 124
121 bool LayoutVideo::shouldDisplayVideo() const { 125 bool LayoutVideo::shouldDisplayVideo() const {
122 return !videoElement()->shouldDisplayPosterImage(); 126 return !videoElement()->shouldDisplayPosterImage();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 LayoutUnit estimatedUsedWidth) const { 170 LayoutUnit estimatedUsedWidth) const {
167 return LayoutReplaced::computeReplacedLogicalHeight(estimatedUsedWidth); 171 return LayoutReplaced::computeReplacedLogicalHeight(estimatedUsedWidth);
168 } 172 }
169 173
170 LayoutUnit LayoutVideo::minimumReplacedHeight() const { 174 LayoutUnit LayoutVideo::minimumReplacedHeight() const {
171 return LayoutReplaced::minimumReplacedHeight(); 175 return LayoutReplaced::minimumReplacedHeight();
172 } 176 }
173 177
174 LayoutRect LayoutVideo::replacedContentRect() const { 178 LayoutRect LayoutVideo::replacedContentRect() const {
175 if (shouldDisplayVideo()) { 179 if (shouldDisplayVideo()) {
176 // Video codecs may need to restart from an I-frame when the output is resiz ed. 180 // Video codecs may need to restart from an I-frame when the output is
177 // Round size in advance to avoid 1px snap difference. 181 // resized. Round size in advance to avoid 1px snap difference.
178 // TODO(trchen): The way of rounding is different from LayoutPart just to ma tch 182 // TODO(trchen): The way of rounding is different from LayoutPart just to
179 // existing behavior. This is probably a bug and We should unify it with Lay outPart. 183 // match existing behavior. This is probably a bug and We should unify it
184 // with LayoutPart.
180 return LayoutRect(pixelSnappedIntRect(computeObjectFit())); 185 return LayoutRect(pixelSnappedIntRect(computeObjectFit()));
181 } 186 }
182 // If we are displaying the poster image no pre-rounding is needed, but the si ze of 187 // If we are displaying the poster image no pre-rounding is needed, but the
183 // the image should be used for fitting instead. 188 // size of the image should be used for fitting instead.
184 return computeObjectFit(&m_cachedImageSize); 189 return computeObjectFit(&m_cachedImageSize);
185 } 190 }
186 191
187 bool LayoutVideo::supportsAcceleratedRendering() const { 192 bool LayoutVideo::supportsAcceleratedRendering() const {
188 return !!mediaElement()->platformLayer(); 193 return !!mediaElement()->platformLayer();
189 } 194 }
190 195
191 static const LayoutBlock* layoutObjectPlaceholder( 196 static const LayoutBlock* layoutObjectPlaceholder(
192 const LayoutObject* layoutObject) { 197 const LayoutObject* layoutObject) {
193 LayoutObject* parent = layoutObject->parent(); 198 LayoutObject* parent = layoutObject->parent();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (element->isFullscreen() && element->usesOverlayFullscreenVideo()) 236 if (element->isFullscreen() && element->usesOverlayFullscreenVideo())
232 return CompositingReasonVideo; 237 return CompositingReasonVideo;
233 238
234 if (shouldDisplayVideo() && supportsAcceleratedRendering()) 239 if (shouldDisplayVideo() && supportsAcceleratedRendering())
235 return CompositingReasonVideo; 240 return CompositingReasonVideo;
236 241
237 return CompositingReasonNone; 242 return CompositingReasonNone;
238 } 243 }
239 244
240 } // namespace blink 245 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutVTTCue.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698