| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // can only be fixed once subpixel precision is available for things lik
e intrinsicWidth/Height - which include zoom! | 307 // can only be fixed once subpixel precision is available for things lik
e intrinsicWidth/Height - which include zoom! |
| 308 constrainedSize.setWidth(RenderBox::computeReplacedLogicalHeight() * int
rinsicSize.width() / intrinsicSize.height()); | 308 constrainedSize.setWidth(RenderBox::computeReplacedLogicalHeight() * int
rinsicSize.width() / intrinsicSize.height()); |
| 309 constrainedSize.setHeight(RenderBox::computeReplacedLogicalWidth() * int
rinsicSize.height() / intrinsicSize.width()); | 309 constrainedSize.setHeight(RenderBox::computeReplacedLogicalWidth() * int
rinsicSize.height() / intrinsicSize.width()); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri
nsicSize) const | 313 LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri
nsicSize) const |
| 314 { | 314 { |
| 315 LayoutRect contentRect = contentBoxRect(); | 315 LayoutRect contentRect = contentBoxRect(); |
| 316 ObjectFit objectFit = style()->objectFit(); | 316 ObjectFit objectFit = style()->objectFit(); |
| 317 if (objectFit == ObjectFitFill) | 317 if (objectFit == ObjectFitFill && style()->objectPosition() == RenderStyle::
initialObjectPosition()) |
| 318 return contentRect; | 318 return contentRect; |
| 319 | 319 |
| 320 LayoutSize intrinsicSize = overriddenIntrinsicSize ? *overriddenIntrinsicSiz
e : this->intrinsicSize(); | 320 LayoutSize intrinsicSize = overriddenIntrinsicSize ? *overriddenIntrinsicSiz
e : this->intrinsicSize(); |
| 321 if (!intrinsicSize.width() || !intrinsicSize.height()) | 321 if (!intrinsicSize.width() || !intrinsicSize.height()) |
| 322 return contentRect; | 322 return contentRect; |
| 323 | 323 |
| 324 LayoutRect finalRect = contentRect; | 324 LayoutRect finalRect = contentRect; |
| 325 switch (objectFit) { | 325 switch (objectFit) { |
| 326 case ObjectFitContain: | 326 case ObjectFitContain: |
| 327 case ObjectFitScaleDown: | 327 case ObjectFitScaleDown: |
| 328 case ObjectFitCover: | 328 case ObjectFitCover: |
| 329 finalRect.setSize(finalRect.size().fitToAspectRatio(intrinsicSize, objec
tFit == ObjectFitCover ? AspectRatioFitGrow : AspectRatioFitShrink)); | 329 finalRect.setSize(finalRect.size().fitToAspectRatio(intrinsicSize, objec
tFit == ObjectFitCover ? AspectRatioFitGrow : AspectRatioFitShrink)); |
| 330 if (objectFit != ObjectFitScaleDown || finalRect.width() <= intrinsicSiz
e.width()) | 330 if (objectFit != ObjectFitScaleDown || finalRect.width() <= intrinsicSiz
e.width()) |
| 331 break; | 331 break; |
| 332 // fall through | 332 // fall through |
| 333 case ObjectFitNone: | 333 case ObjectFitNone: |
| 334 finalRect.setSize(intrinsicSize); | 334 finalRect.setSize(intrinsicSize); |
| 335 break; | 335 break; |
| 336 case ObjectFitFill: | 336 case ObjectFitFill: |
| 337 break; |
| 338 default: |
| 337 ASSERT_NOT_REACHED(); | 339 ASSERT_NOT_REACHED(); |
| 338 } | 340 } |
| 339 | 341 |
| 340 // FIXME: This is where object-position should be taken into account, but si
nce it's not | 342 LayoutUnit xOffset = minimumValueForLength(style()->objectPosition().x(), co
ntentRect.width() - finalRect.width(), view()); |
| 341 // implemented yet, assume the initial value of "50% 50%". | 343 LayoutUnit yOffset = minimumValueForLength(style()->objectPosition().y(), co
ntentRect.height() - finalRect.height(), view()); |
| 342 LayoutUnit xOffset = (contentRect.width() - finalRect.width()) / 2; | |
| 343 LayoutUnit yOffset = (contentRect.height() - finalRect.height()) / 2; | |
| 344 finalRect.move(xOffset, yOffset); | 344 finalRect.move(xOffset, yOffset); |
| 345 | 345 |
| 346 return finalRect; | 346 return finalRect; |
| 347 } | 347 } |
| 348 | 348 |
| 349 void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
double& intrinsicRatio, bool& isPercentageIntrinsicSize) const | 349 void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
double& intrinsicRatio, bool& isPercentageIntrinsicSize) const |
| 350 { | 350 { |
| 351 // If there's an embeddedContentBox() of a remote, referenced document avail
able, this code-path should never be used. | 351 // If there's an embeddedContentBox() of a remote, referenced document avail
able, this code-path should never be used. |
| 352 ASSERT(!embeddedContentBox()); | 352 ASSERT(!embeddedContentBox()); |
| 353 isPercentageIntrinsicSize = false; | 353 isPercentageIntrinsicSize = false; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 | 609 |
| 610 if (style()) { | 610 if (style()) { |
| 611 if (v) | 611 if (v) |
| 612 r.inflate(style()->outlineSize()); | 612 r.inflate(style()->outlineSize()); |
| 613 } | 613 } |
| 614 computeRectForRepaint(repaintContainer, r); | 614 computeRectForRepaint(repaintContainer, r); |
| 615 return r; | 615 return r; |
| 616 } | 616 } |
| 617 | 617 |
| 618 } | 618 } |
| OLD | NEW |