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