OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
10 * | 10 * |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 | 332 |
333 void LayoutImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou
ble& intrinsicRatio) const | 333 void LayoutImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou
ble& intrinsicRatio) const |
334 { | 334 { |
335 LayoutReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat
io); | 335 LayoutReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat
io); |
336 | 336 |
337 // Our intrinsicSize is empty if we're rendering generated images with relat
ive width/height. Figure out the right intrinsic size to use. | 337 // Our intrinsicSize is empty if we're rendering generated images with relat
ive width/height. Figure out the right intrinsic size to use. |
338 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() ||
m_imageResource->imageHasRelativeHeight())) { | 338 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() ||
m_imageResource->imageHasRelativeHeight())) { |
339 LayoutObject* containingBlock = isOutOfFlowPositioned() ? container() :
this->containingBlock(); | 339 LayoutObject* containingBlock = isOutOfFlowPositioned() ? container() :
this->containingBlock(); |
340 if (containingBlock->isBox()) { | 340 if (containingBlock->isBox()) { |
341 RenderBox* box = toRenderBox(containingBlock); | 341 LayoutBox* box = toLayoutBox(containingBlock); |
342 intrinsicSize.setWidth(box->availableLogicalWidth().toFloat()); | 342 intrinsicSize.setWidth(box->availableLogicalWidth().toFloat()); |
343 intrinsicSize.setHeight(box->availableLogicalHeight(IncludeMarginBor
derPadding).toFloat()); | 343 intrinsicSize.setHeight(box->availableLogicalHeight(IncludeMarginBor
derPadding).toFloat()); |
344 } | 344 } |
345 } | 345 } |
346 // Don't compute an intrinsic ratio to preserve historical WebKit behavior i
f we're painting alt text and/or a broken image. | 346 // Don't compute an intrinsic ratio to preserve historical WebKit behavior i
f we're painting alt text and/or a broken image. |
347 // Video is excluded from this behavior because video elements have a defaul
t aspect ratio that a failed poster image load should not override. | 347 // Video is excluded from this behavior because video elements have a defaul
t aspect ratio that a failed poster image load should not override. |
348 if (m_imageResource && m_imageResource->errorOccurred() && !isVideo()) { | 348 if (m_imageResource && m_imageResource->errorOccurred() && !isVideo()) { |
349 intrinsicRatio = 1; | 349 intrinsicRatio = 1; |
350 return; | 350 return; |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 bool LayoutImage::needsPreferredWidthsRecalculation() const | 354 bool LayoutImage::needsPreferredWidthsRecalculation() const |
355 { | 355 { |
356 if (LayoutReplaced::needsPreferredWidthsRecalculation()) | 356 if (LayoutReplaced::needsPreferredWidthsRecalculation()) |
357 return true; | 357 return true; |
358 return embeddedContentBox(); | 358 return embeddedContentBox(); |
359 } | 359 } |
360 | 360 |
361 RenderBox* LayoutImage::embeddedContentBox() const | 361 LayoutBox* LayoutImage::embeddedContentBox() const |
362 { | 362 { |
363 if (!m_imageResource) | 363 if (!m_imageResource) |
364 return 0; | 364 return 0; |
365 | 365 |
366 ImageResource* cachedImage = m_imageResource->cachedImage(); | 366 ImageResource* cachedImage = m_imageResource->cachedImage(); |
367 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 367 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
368 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 368 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
369 | 369 |
370 return 0; | 370 return 0; |
371 } | 371 } |
372 | 372 |
373 } // namespace blink | 373 } // namespace blink |
OLD | NEW |