| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return false; | 223 return false; |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool RenderReplaced::needsPreferredWidthsRecalculation() const | 226 bool RenderReplaced::needsPreferredWidthsRecalculation() const |
| 227 { | 227 { |
| 228 // If the height is a percentage and the width is auto, then the containingB
locks's height changing can cause | 228 // If the height is a percentage and the width is auto, then the containingB
locks's height changing can cause |
| 229 // this node to change it's preferred width because it maintains aspect rati
o. | 229 // this node to change it's preferred width because it maintains aspect rati
o. |
| 230 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto() && !ha
sAutoHeightOrContainingBlockWithAutoHeight(); | 230 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto() && !ha
sAutoHeightOrContainingBlockWithAutoHeight(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 static inline bool rendererHasAspectRatio(const RenderObject* renderer) | |
| 234 { | |
| 235 ASSERT(renderer); | |
| 236 return renderer->isImage() || renderer->isCanvas() || renderer->isVideo(); | |
| 237 } | |
| 238 | |
| 239 void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
tRenderer, FloatSize& constrainedSize, double& intrinsicRatio) const | 233 void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
tRenderer, FloatSize& constrainedSize, double& intrinsicRatio) const |
| 240 { | 234 { |
| 241 FloatSize intrinsicSize; | 235 FloatSize intrinsicSize; |
| 242 if (contentRenderer) { | 236 if (contentRenderer) { |
| 243 contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrins
icRatio); | 237 contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrins
icRatio); |
| 244 | 238 |
| 245 // Handle zoom & vertical writing modes here, as the embedded document d
oesn't know about them. | 239 // Handle zoom & vertical writing modes here, as the embedded document d
oesn't know about them. |
| 246 intrinsicSize.scale(style()->effectiveZoom()); | 240 intrinsicSize.scale(style()->effectiveZoom()); |
| 247 if (isRenderImage()) | 241 if (isRenderImage()) |
| 248 intrinsicSize.scale(toRenderImage(this)->imageDevicePixelRatio()); | 242 intrinsicSize.scale(toRenderImage(this)->imageDevicePixelRatio()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return finalRect; | 313 return finalRect; |
| 320 } | 314 } |
| 321 | 315 |
| 322 void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
double& intrinsicRatio) const | 316 void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
double& intrinsicRatio) const |
| 323 { | 317 { |
| 324 // If there's an embeddedContentBox() of a remote, referenced document avail
able, this code-path should never be used. | 318 // If there's an embeddedContentBox() of a remote, referenced document avail
able, this code-path should never be used. |
| 325 ASSERT(!embeddedContentBox()); | 319 ASSERT(!embeddedContentBox()); |
| 326 intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogica
lHeight().toFloat()); | 320 intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogica
lHeight().toFloat()); |
| 327 | 321 |
| 328 // Figure out if we need to compute an intrinsic ratio. | 322 // Figure out if we need to compute an intrinsic ratio. |
| 329 if (intrinsicSize.isEmpty() || !rendererHasAspectRatio(this)) | 323 if (intrinsicSize.isEmpty() || !hasAspectRatio()) |
| 330 return; | 324 return; |
| 331 | 325 |
| 332 intrinsicRatio = intrinsicSize.width() / intrinsicSize.height(); | 326 intrinsicRatio = intrinsicSize.width() / intrinsicSize.height(); |
| 333 } | 327 } |
| 334 | 328 |
| 335 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const | 329 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const |
| 336 { | 330 { |
| 337 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) | 331 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) |
| 338 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL
ogicalWidthUsing(style()->logicalWidth()), shouldComputePreferred); | 332 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL
ogicalWidthUsing(style()->logicalWidth()), shouldComputePreferred); |
| 339 | 333 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 return LayoutRect(); | 563 return LayoutRect(); |
| 570 | 564 |
| 571 // The selectionRect can project outside of the overflowRect, so take their
union | 565 // The selectionRect can project outside of the overflowRect, so take their
union |
| 572 // for repainting to avoid selection painting glitches. | 566 // for repainting to avoid selection painting glitches. |
| 573 LayoutRect r = isSelected() ? localSelectionRect() : visualOverflowRect(); | 567 LayoutRect r = isSelected() ? localSelectionRect() : visualOverflowRect(); |
| 574 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r); | 568 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r); |
| 575 return r; | 569 return r; |
| 576 } | 570 } |
| 577 | 571 |
| 578 } | 572 } |
| OLD | NEW |