| 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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 return IntSize(solutionWidth, size.height()); | 948 return IntSize(solutionWidth, size.height()); |
| 949 } | 949 } |
| 950 | 950 |
| 951 // Only the second solution fits, assert that. | 951 // Only the second solution fits, assert that. |
| 952 ASSERT(solutionHeight <= size.height()); | 952 ASSERT(solutionHeight <= size.height()); |
| 953 return IntSize(size.width(), solutionHeight); | 953 return IntSize(size.width(), solutionHeight); |
| 954 } | 954 } |
| 955 | 955 |
| 956 IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
e, const IntSize& positioningAreaSize) const | 956 IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
e, const IntSize& positioningAreaSize) const |
| 957 { | 957 { |
| 958 int resolvedWidth = 0; | 958 // A generated image without a fixed size, will always return the container
size as intrinsic size. |
| 959 int resolvedHeight = 0; | 959 if (image->isGeneratedImage() && image->usesImageContainerSize()) |
| 960 return IntSize(positioningAreaSize.width(), positioningAreaSize.height()
); |
| 961 |
| 962 Length intrinsicWidth; |
| 963 Length intrinsicHeight; |
| 960 FloatSize intrinsicRatio; | 964 FloatSize intrinsicRatio; |
| 965 image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, int
rinsicRatio); |
| 961 | 966 |
| 962 // A generated image without a fixed size, will always return the container
size as intrinsic size. | 967 // Intrinsic dimensions expressed as percentages must be resolved relative t
o the dimensions of the rectangle |
| 963 if (image->isGeneratedImage() && image->usesImageContainerSize()) { | 968 // that establishes the coordinate system for the 'background-position' prop
erty. |
| 964 resolvedWidth = positioningAreaSize.width(); | 969 |
| 965 resolvedHeight = positioningAreaSize.height(); | 970 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/
63656 |
| 966 } else { | 971 if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrinsicRa
tio.isEmpty()) { |
| 967 Length intrinsicWidth; | 972 // Resolve width/height percentages against positioningAreaSize, only if
no intrinsic ratio is provided. |
| 968 Length intrinsicHeight; | 973 int resolvedWidth = static_cast<int>(round(positioningAreaSize.width() *
intrinsicWidth.percent() / 100)); |
| 969 image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight,
intrinsicRatio); | 974 int resolvedHeight = static_cast<int>(round(positioningAreaSize.height()
* intrinsicHeight.percent() / 100)); |
| 970 | 975 return IntSize(resolvedWidth, resolvedHeight); |
| 971 // Intrinsic dimensions expressed as percentages must be resolved relati
ve to the dimensions of the rectangle | |
| 972 // that establishes the coordinate system for the 'background-position'
property. | |
| 973 | |
| 974 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.or
g/b/63656 | |
| 975 if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrins
icRatio.isEmpty()) { | |
| 976 // Resolve width/height percentages against positioningAreaSize, onl
y if no intrinsic ratio is provided. | |
| 977 resolvedWidth = static_cast<int>(round(positioningAreaSize.width() *
intrinsicWidth.percent() / 100)); | |
| 978 resolvedHeight = static_cast<int>(round(positioningAreaSize.height()
* intrinsicHeight.percent() / 100)); | |
| 979 } else { | |
| 980 if (intrinsicWidth.isFixed()) | |
| 981 resolvedWidth = static_cast<int>(intrinsicWidth.value() * style(
)->effectiveZoom()); | |
| 982 if (intrinsicHeight.isFixed()) | |
| 983 resolvedHeight = static_cast<int>(intrinsicHeight.value() * styl
e()->effectiveZoom()); | |
| 984 } | |
| 985 } | 976 } |
| 986 | 977 |
| 987 if (resolvedWidth > 0 && resolvedHeight > 0) | 978 IntSize resolvedSize(intrinsicWidth.isFixed() ? intrinsicWidth.value() : 0,
intrinsicHeight.isFixed() ? intrinsicHeight.value() : 0); |
| 988 return IntSize(resolvedWidth, resolvedHeight); | 979 IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height()
> 0 ? 1 : 0); |
| 980 resolvedSize.scale(style()->effectiveZoom()); |
| 981 resolvedSize.clampToMinimumSize(minimumSize); |
| 982 |
| 983 if (!resolvedSize.isEmpty()) |
| 984 return resolvedSize; |
| 989 | 985 |
| 990 // If the image has one of either an intrinsic width or an intrinsic height: | 986 // If the image has one of either an intrinsic width or an intrinsic height: |
| 991 // * and an intrinsic aspect ratio, then the missing dimension is calculated
from the given dimension and the ratio. | 987 // * and an intrinsic aspect ratio, then the missing dimension is calculated
from the given dimension and the ratio. |
| 992 // * and no intrinsic aspect ratio, then the missing dimension is assumed to
be the size of the rectangle that | 988 // * and no intrinsic aspect ratio, then the missing dimension is assumed to
be the size of the rectangle that |
| 993 // establishes the coordinate system for the 'background-position' propert
y. | 989 // establishes the coordinate system for the 'background-position' propert
y. |
| 994 if ((resolvedWidth && !resolvedHeight) || (!resolvedWidth && resolvedHeight)
) | 990 if (resolvedSize.width() > 0 || resolvedSize.height() > 0) |
| 995 return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize,
intrinsicRatio, resolvedWidth, resolvedHeight); | 991 return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize,
intrinsicRatio, resolvedSize.width(), resolvedSize.height()); |
| 996 | 992 |
| 997 // If the image has no intrinsic dimensions and has an intrinsic ratio the d
imensions must be assumed to be the | 993 // If the image has no intrinsic dimensions and has an intrinsic ratio the d
imensions must be assumed to be the |
| 998 // largest dimensions at that ratio such that neither dimension exceeds the
dimensions of the rectangle that | 994 // largest dimensions at that ratio such that neither dimension exceeds the
dimensions of the rectangle that |
| 999 // establishes the coordinate system for the 'background-position' property. | 995 // establishes the coordinate system for the 'background-position' property. |
| 1000 if (!resolvedWidth && !resolvedHeight && !intrinsicRatio.isEmpty()) | 996 if (!intrinsicRatio.isEmpty()) |
| 1001 return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio)
; | 997 return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio)
; |
| 1002 | 998 |
| 1003 // If the image has no intrinsic ratio either, then the dimensions must be a
ssumed to be the rectangle that | 999 // If the image has no intrinsic ratio either, then the dimensions must be a
ssumed to be the rectangle that |
| 1004 // establishes the coordinate system for the 'background-position' property. | 1000 // establishes the coordinate system for the 'background-position' property. |
| 1005 return positioningAreaSize; | 1001 return positioningAreaSize; |
| 1006 } | 1002 } |
| 1007 | 1003 |
| 1008 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
const IntSize& positioningAreaSize) const | 1004 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
const IntSize& positioningAreaSize) const |
| 1009 { | 1005 { |
| 1010 StyleImage* image = fillLayer->image(); | 1006 StyleImage* image = fillLayer->image(); |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2933 bool preserve3D = useTransforms && (o->style()->preserves3D() || style()->pr
eserves3D()); | 2929 bool preserve3D = useTransforms && (o->style()->preserves3D() || style()->pr
eserves3D()); |
| 2934 if (useTransforms && shouldUseTransformFromContainer(o)) { | 2930 if (useTransforms && shouldUseTransformFromContainer(o)) { |
| 2935 TransformationMatrix t; | 2931 TransformationMatrix t; |
| 2936 getTransformFromContainer(o, containerOffset, t); | 2932 getTransformFromContainer(o, containerOffset, t); |
| 2937 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate
Transform : TransformState::FlattenTransform); | 2933 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate
Transform : TransformState::FlattenTransform); |
| 2938 } else | 2934 } else |
| 2939 transformState.move(containerOffset.width(), containerOffset.height(), p
reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo
rm); | 2935 transformState.move(containerOffset.width(), containerOffset.height(), p
reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo
rm); |
| 2940 } | 2936 } |
| 2941 | 2937 |
| 2942 } // namespace WebCore | 2938 } // namespace WebCore |
| OLD | NEW |