Changeset 67770 in webkit
- Timestamp:
- Sep 17, 2010, 7:09:08 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r67766 r67770 1 2010-09-17 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Simon Fraser. 4 5 Canvas sizing ignores intrinsic size 6 https://bugs.webkit.org/show_bug.cgi?id=46024 7 8 * fast/replaced/table-percent-height-expected.txt: Updated. 9 * fast/replaced/table-percent-height.html: Changed to expect canvas to maintain 10 its intrinsic ratio. 11 1 12 2010-09-17 Adam Barth <abarth@webkit.org> 2 13 -
trunk/LayoutTests/fast/replaced/table-percent-height-expected.txt
r53897 r67770 29 29 30 30 31 PASS getWidth('canvas-75') is ' 300px'31 PASS getWidth('canvas-75') is '224px' 32 32 PASS getHeight('canvas-75') is '112px' 33 33 PASS getWidth('canvas-100') is '300px' -
trunk/LayoutTests/fast/replaced/table-percent-height.html
r53897 r67770 62 62 description("This test checks that replaced elements with percentage heights within table cells have the correct height.<br>Note, some of the button height tests fail on the Windows ports. See bug #34071."); 63 63 64 shouldBe("getWidth('canvas-75')", "' 300px'");64 shouldBe("getWidth('canvas-75')", "'224px'"); 65 65 shouldBe("getHeight('canvas-75')", "'112px'"); 66 66 shouldBe("getWidth('canvas-100')", "'300px'"); -
trunk/WebCore/ChangeLog
r67767 r67770 1 2010-09-17 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Simon Fraser. 4 5 Canvas sizing ignores intrinsic size 6 https://bugs.webkit.org/show_bug.cgi?id=46024 7 8 Updated fast/replaced/table-percent-height.html 9 10 * rendering/RenderEmbeddedObject.cpp: 11 (WebCore::RenderEmbeddedObject::RenderEmbeddedObject): If this is used as a proxy 12 for <video>, behave like it has an intrinsic size (e.g. preserve aspect ratio when 13 width is auto and height is specified). 14 * rendering/RenderImage.cpp: 15 (WebCore::RenderImage::calcAspectRatioWidth): Changed to explicitly invoke 16 RenderBox::calcReplacedHeight(), now that RenderReplaced has its own implementation 17 which we don’t want. 18 (WebCore::RenderImage::calcAspectRatioHeight): Similarly with calcReplacedWidth(). 19 * rendering/RenderImage.h: 20 * rendering/RenderReplaced.cpp: 21 (WebCore::RenderReplaced::RenderReplaced): Initialize m_hasIntrinsicSize. 22 (WebCore::lengthIsSpecified): Added this helper function, based on RenderImage’s 23 is{Width,Height}Specified(). 24 (WebCore::RenderReplaced::calcReplacedWidth): Moved from RenderVideo all the way 25 up here so other replaced objects could use this logic. 26 (WebCore::RenderReplaced::calcReplacedHeight): Ditto. 27 (WebCore::RenderReplaced::calcAspectRatioWidth): Ditto. 28 (WebCore::RenderReplaced::calcAspectRatioHeight): Ditto. 29 (WebCore::RenderReplaced::calcPrefWidths): Replaced with the RenderImage version 30 of the logic. 31 (WebCore::RenderReplaced::setIntrinsicSize): Added an assertion. 32 * rendering/RenderReplaced.h: 33 (WebCore::RenderReplaced::minimumReplacedHeight): Promoted from private to protected 34 to allow RenderVideo to call through. 35 (WebCore::RenderReplaced::setHasIntrinsicSize): Added this setter. 36 * rendering/RenderVideo.cpp: 37 (WebCore::RenderVideo::updateIntrinsicSize): Factor zoom into the intrinsic size, 38 the way other RenderReplaced objects do. 39 (WebCore::RenderVideo::calcReplacedWidth): Invoke the RenderReplaced implementation, 40 which matches what used to be here, skipping over the RenderImage implementation. 41 (WebCore::RenderVideo::calcReplacedHeight): Ditto. 42 (WebCore::RenderVideo::minimumReplacedHeight): Ditto. 43 * rendering/RenderVideo.h: 44 1 45 2010-09-17 Darin Adler <darin@apple.com> 2 46 -
trunk/WebCore/rendering/RenderEmbeddedObject.cpp
r67746 r67770 80 80 { 81 81 view()->frameView()->setIsVisuallyNonEmpty(); 82 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) 83 if (element->hasTagName(videoTag) || element->hasTagName(audioTag)) 84 setHasIntrinsicSize(); 85 #endif 82 86 } 83 87 -
trunk/WebCore/rendering/RenderImage.cpp
r66223 r67770 482 482 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) 483 483 return size.width(); // Don't bother scaling. 484 return Render Replaced::calcReplacedHeight() * size.width() / size.height();484 return RenderBox::calcReplacedHeight() * size.width() / size.height(); 485 485 } 486 486 … … 492 492 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) 493 493 return size.height(); // Don't bother scaling. 494 return RenderReplaced::calcReplacedWidth() * size.height() / size.width(); 495 } 496 497 void RenderImage::calcPrefWidths() 498 { 499 ASSERT(prefWidthsDirty()); 500 501 int borderAndPadding = borderAndPaddingWidth(); 502 m_maxPrefWidth = calcReplacedWidth(false) + borderAndPadding; 503 504 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) 505 m_maxPrefWidth = min(m_maxPrefWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0)); 506 507 if (style()->width().isPercent() || style()->height().isPercent() || 508 style()->maxWidth().isPercent() || style()->maxHeight().isPercent() || 509 style()->minWidth().isPercent() || style()->minHeight().isPercent()) 510 m_minPrefWidth = 0; 511 else 512 m_minPrefWidth = m_maxPrefWidth; 513 514 setPrefWidthsDirty(false); 494 return RenderBox::calcReplacedWidth() * size.height() / size.width(); 515 495 } 516 496 -
trunk/WebCore/rendering/RenderImage.h
r66223 r67770 80 80 virtual int calcReplacedHeight() const; 81 81 82 virtual void calcPrefWidths();83 84 82 int calcAspectRatioWidth() const; 85 83 int calcAspectRatioHeight() const; -
trunk/WebCore/rendering/RenderReplaced.cpp
r62104 r67770 41 41 : RenderBox(node) 42 42 , m_intrinsicSize(cDefaultWidth, cDefaultHeight) 43 , m_hasIntrinsicSize(false) 43 44 { 44 45 setReplaced(true); … … 48 49 : RenderBox(node) 49 50 , m_intrinsicSize(intrinsicSize) 51 , m_hasIntrinsicSize(true) 50 52 { 51 53 setReplaced(true); … … 193 195 } 194 196 197 static inline bool lengthIsSpecified(Length length) 198 { 199 LengthType lengthType = length.type(); 200 return lengthType == Fixed || lengthType == Percent; 201 } 202 203 int RenderReplaced::calcReplacedWidth(bool includeMaxWidth) const 204 { 205 int width; 206 if (lengthIsSpecified(style()->width())) 207 width = calcReplacedWidthUsing(style()->width()); 208 else if (m_hasIntrinsicSize) 209 width = calcAspectRatioWidth(); 210 else 211 width = intrinsicSize().width(); 212 213 int minW = calcReplacedWidthUsing(style()->minWidth()); 214 int maxW = !includeMaxWidth || style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth()); 215 216 return max(minW, min(width, maxW)); 217 } 218 219 int RenderReplaced::calcReplacedHeight() const 220 { 221 int height; 222 if (lengthIsSpecified(style()->height())) 223 height = calcReplacedHeightUsing(style()->height()); 224 else if (m_hasIntrinsicSize) 225 height = calcAspectRatioHeight(); 226 else 227 height = intrinsicSize().height(); 228 229 int minH = calcReplacedHeightUsing(style()->minHeight()); 230 int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight()); 231 232 return max(minH, min(height, maxH)); 233 } 234 235 int RenderReplaced::calcAspectRatioWidth() const 236 { 237 int intrinsicWidth = intrinsicSize().width(); 238 int intrinsicHeight = intrinsicSize().height(); 239 if (!intrinsicHeight) 240 return 0; 241 return RenderBox::calcReplacedHeight() * intrinsicWidth / intrinsicHeight; 242 } 243 244 int RenderReplaced::calcAspectRatioHeight() const 245 { 246 int intrinsicWidth = intrinsicSize().width(); 247 int intrinsicHeight = intrinsicSize().height(); 248 if (!intrinsicWidth) 249 return 0; 250 return RenderBox::calcReplacedWidth() * intrinsicHeight / intrinsicWidth; 251 } 252 195 253 void RenderReplaced::calcPrefWidths() 196 254 { … … 198 256 199 257 int borderAndPadding = borderAndPaddingWidth(); 200 int width = calcReplacedWidth(false) + borderAndPadding;258 m_maxPrefWidth = calcReplacedWidth(false) + borderAndPadding; 201 259 202 260 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) 203 width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0)); 204 205 if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) { 261 m_maxPrefWidth = min(m_maxPrefWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0)); 262 263 if (style()->width().isPercent() || style()->height().isPercent() 264 || style()->maxWidth().isPercent() || style()->maxHeight().isPercent() 265 || style()->minWidth().isPercent() || style()->minHeight().isPercent()) 206 266 m_minPrefWidth = 0; 207 m_maxPrefWidth = width; 208 } else 209 m_minPrefWidth = m_maxPrefWidth = width; 267 else 268 m_minPrefWidth = m_maxPrefWidth; 210 269 211 270 setPrefWidthsDirty(false); … … 330 389 void RenderReplaced::setIntrinsicSize(const IntSize& size) 331 390 { 391 ASSERT(m_hasIntrinsicSize); 332 392 m_intrinsicSize = size; 333 393 } -
trunk/WebCore/rendering/RenderReplaced.h
r56206 r67770 38 38 virtual IntSize intrinsicSize() const; 39 39 40 virtual int calcReplacedWidth(bool includeMaxWidth = true) const; 41 virtual int calcReplacedHeight() const; 42 virtual int minimumReplacedHeight() const { return 0; } 43 40 44 virtual void setSelectionState(SelectionState); 41 45 … … 46 50 void setIntrinsicSize(const IntSize&); 47 51 virtual void intrinsicSizeChanged(); 52 void setHasIntrinsicSize() { m_hasIntrinsicSize = true; } 48 53 49 54 virtual void paint(PaintInfo&, int tx, int ty); … … 61 66 virtual void calcPrefWidths(); 62 67 63 virtual int minimumReplacedHeight() const { return 0; } 68 int calcAspectRatioWidth() const; 69 int calcAspectRatioHeight() const; 64 70 65 71 virtual void paintReplaced(PaintInfo&, int /*tx*/, int /*ty*/) { } … … 75 81 76 82 IntSize m_intrinsicSize; 83 bool m_hasIntrinsicSize; 77 84 }; 78 85 -
trunk/WebCore/rendering/RenderVideo.cpp
r66223 r67770 81 81 { 82 82 IntSize size = calculateIntrinsicSize(); 83 size.scale(style()->effectiveZoom()); 83 84 84 85 // Never set the element size to zero when in a media document. … … 251 252 int RenderVideo::calcReplacedWidth(bool includeMaxWidth) const 252 253 { 253 int width; 254 if (isWidthSpecified()) 255 width = calcReplacedWidthUsing(style()->width()); 256 else 257 width = calcAspectRatioWidth() * style()->effectiveZoom(); 258 259 int minW = calcReplacedWidthUsing(style()->minWidth()); 260 int maxW = !includeMaxWidth || style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth()); 261 262 return max(minW, min(width, maxW)); 254 return RenderReplaced::calcReplacedWidth(includeMaxWidth); 263 255 } 264 256 265 257 int RenderVideo::calcReplacedHeight() const 266 258 { 267 int height; 268 if (isHeightSpecified()) 269 height = calcReplacedHeightUsing(style()->height()); 270 else 271 height = calcAspectRatioHeight() * style()->effectiveZoom(); 272 273 int minH = calcReplacedHeightUsing(style()->minHeight()); 274 int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight()); 275 276 return max(minH, min(height, maxH)); 277 } 278 279 int RenderVideo::calcAspectRatioWidth() const 280 { 281 int intrinsicWidth = intrinsicSize().width(); 282 int intrinsicHeight = intrinsicSize().height(); 283 if (!intrinsicHeight) 284 return 0; 285 return RenderBox::calcReplacedHeight() * intrinsicWidth / intrinsicHeight; 286 } 287 288 int RenderVideo::calcAspectRatioHeight() const 289 { 290 int intrinsicWidth = intrinsicSize().width(); 291 int intrinsicHeight = intrinsicSize().height(); 292 if (!intrinsicWidth) 293 return 0; 294 return RenderBox::calcReplacedWidth() * intrinsicHeight / intrinsicWidth; 259 return RenderReplaced::calcReplacedHeight(); 295 260 } 296 261 297 262 int RenderVideo::minimumReplacedHeight() const 298 263 { 299 return 0;264 return RenderReplaced::minimumReplacedHeight(); 300 265 } 301 266 -
trunk/WebCore/rendering/RenderVideo.h
r64997 r67770 75 75 virtual int minimumReplacedHeight() const; 76 76 77 int calcAspectRatioWidth() const;78 int calcAspectRatioHeight() const;79 80 77 void updatePlayer(); 81 78
Note:
See TracChangeset
for help on using the changeset viewer.