Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (99018 => 99019)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2011-11-02 00:36:20 UTC (rev 99018)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2011-11-02 00:55:49 UTC (rev 99019)
@@ -833,10 +833,10 @@
return LayoutSize(size.width(), solutionHeight);
}
-LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize) const
+IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize) const
{
- LayoutUnit resolvedWidth = 0;
- LayoutUnit resolvedHeight = 0;
+ int resolvedWidth = 0;
+ int resolvedHeight = 0;
FloatSize intrinsicRatio;
// A generated image without a fixed size, will always return the container size as intrinsic size.
@@ -850,16 +850,16 @@
// FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
if (intrinsicWidth.isFixed())
- resolvedWidth = static_cast<LayoutUnit>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
+ resolvedWidth = static_cast<int>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
if (intrinsicHeight.isFixed())
- resolvedHeight = static_cast<LayoutUnit>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
+ resolvedHeight = static_cast<int>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
}
// Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
// that establishes the coordinate system for the 'background-position' property. SVG on the other hand
// _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions.
if (resolvedWidth > 0 && resolvedHeight > 0)
- return LayoutSize(resolvedWidth, resolvedHeight);
+ return IntSize(resolvedWidth, resolvedHeight);
// If the image has one of either an intrinsic width or an intrinsic height:
// * and an intrinsic aspect ratio, then the missing dimension is calculated from the given dimension and the ratio.
@@ -879,17 +879,17 @@
return positioningAreaSize;
}
-LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const LayoutSize& positioningAreaSize) const
+IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const
{
StyleImage* image = fillLayer->image();
EFillSizeType type = fillLayer->size().type;
- LayoutSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
+ IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
switch (type) {
case SizeLength: {
- LayoutUnit w = positioningAreaSize.width();
- LayoutUnit h = positioningAreaSize.height();
+ int w = positioningAreaSize.width();
+ int h = positioningAreaSize.height();
Length layerWidth = fillLayer->size().size.width();
Length layerHeight = fillLayer->size().size.height();
@@ -918,7 +918,7 @@
h = imageIntrinsicSize.height();
}
- return LayoutSize(max<LayoutUnit>(1, w), max<LayoutUnit>(1, h));
+ return IntSize(max(1, w), max(1, h));
}
case SizeNone: {
// If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
@@ -935,12 +935,12 @@
float verticalScaleFactor = imageIntrinsicSize.height()
? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicSize.height() : 1;
float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor);
- return LayoutSize(max<LayoutUnit>(1, imageIntrinsicSize.width() * scaleFactor), max<LayoutUnit>(1, imageIntrinsicSize.height() * scaleFactor));
+ return IntSize(max(1, static_cast<int>(imageIntrinsicSize.width() * scaleFactor)), max(1, static_cast<int>(imageIntrinsicSize.height() * scaleFactor)));
}
}
ASSERT_NOT_REACHED();
- return LayoutSize();
+ return IntSize();
}
void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX(int xOffset)
@@ -956,19 +956,20 @@
m_destRect.setHeight(m_tileSize.height() + min(yOffset, 0));
}
-void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint)
+void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const IntPoint& attachmentPoint)
{
- m_phase.move(max<LayoutUnit>(attachmentPoint.x() - m_destRect.x(), 0), max<LayoutUnit>(attachmentPoint.y() - m_destRect.y(), 0));
+ IntPoint alignedPoint = attachmentPoint;
+ m_phase.move(max(alignedPoint.x() - m_destRect.x(), 0), max(alignedPoint.y() - m_destRect.y(), 0));
}
-void RenderBoxModelObject::BackgroundImageGeometry::clip(const LayoutRect& clipRect)
+void RenderBoxModelObject::BackgroundImageGeometry::clip(const IntRect& clipRect)
{
m_destRect.intersect(clipRect);
}
-LayoutPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
+IntPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
{
- LayoutPoint phase = m_phase;
+ IntPoint phase = m_phase;
phase += m_destRect.location() - m_destOrigin;
return phase;
}
@@ -978,7 +979,7 @@
{
LayoutUnit left = 0;
LayoutUnit top = 0;
- LayoutSize positioningAreaSize;
+ IntSize positioningAreaSize;
// Determine the background positioning area and set destRect to the background painting area.
// destRect will be adjusted later if the background is non-repeating.
@@ -1027,7 +1028,7 @@
positioningAreaSize = geometry.destRect().size();
}
- LayoutSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
+ IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
fillLayer->image()->setContainerSizeForRenderer(this, fillTileSize, style()->effectiveZoom());
geometry.setTileSize(fillTileSize);
@@ -1036,13 +1037,13 @@
LayoutUnit xPosition = fillLayer->xPosition().calcMinValue(positioningAreaSize.width() - geometry.tileSize().width(), true);
if (backgroundRepeatX == RepeatFill)
- geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : 0);
+ geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : LayoutUnit(0));
else
geometry.setNoRepeatX(xPosition + left);
LayoutUnit yPosition = fillLayer->yPosition().calcMinValue(positioningAreaSize.height() - geometry.tileSize().height(), true);
if (backgroundRepeatY == RepeatFill)
- geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : 0);
+ geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : LayoutUnit(0));
else
geometry.setNoRepeatY(yPosition + top);
@@ -1089,19 +1090,19 @@
LayoutUnit rightWithOutset = rect.maxX() + rightOutset;
LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
- LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
+ IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
// If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
- LayoutSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;
+ IntSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;
styleImage->setContainerSizeForRenderer(this, containerSize, style->effectiveZoom());
- LayoutUnit imageWidth = imageSize.width();
- LayoutUnit imageHeight = imageSize.height();
+ int imageWidth = imageSize.width();
+ int imageHeight = imageSize.height();
- LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));
- LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));
- LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));
- LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));
+ int topSlice = min<int>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));
+ int rightSlice = min<int>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));
+ int bottomSlice = min<int>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));
+ int leftSlice = min<int>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));
ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
ENinePieceImageRule vRule = ninePieceImage.verticalRule();
@@ -1115,8 +1116,8 @@
// The spec says: Given Lwidth as the width of the border image area, Lheight as its height, and Wside as the border image width
// offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all W are reduced by
// multiplying them by f.
- int borderSideWidth = max(1, leftWidth + rightWidth);
- int borderSideHeight = max(1, topWidth + bottomWidth);
+ LayoutUnit borderSideWidth = max<LayoutUnit>(1, leftWidth + rightWidth);
+ LayoutUnit borderSideHeight = max<LayoutUnit>(1, topWidth + bottomWidth);
float borderSideScaleFactor = min((float)borderImageRect.width() / borderSideWidth, (float)borderImageRect.height() / borderSideHeight);
if (borderSideScaleFactor < 1) {
topWidth *= borderSideScaleFactor;
@@ -1163,9 +1164,9 @@
// Paint the left edge.
// Have to scale and tile into the border rect.
- graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
+ graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
destinationHeight),
- LayoutRect(0, topSlice, leftSlice, sourceHeight),
+ IntRect(0, topSlice, leftSlice, sourceHeight),
FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op);
}
@@ -1184,24 +1185,24 @@
LayoutRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
// Paint the right edge.
- graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
+ graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
destinationHeight),
- LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
+ IntRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
FloatSize(rightSideScale, rightSideScale),
Image::StretchTile, (Image::TileRule)vRule, op);
}
// Paint the top edge.
if (drawTop)
- graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
- LayoutRect(leftSlice, 0, sourceWidth, topSlice),
+ graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
+ IntRect(leftSlice, 0, sourceWidth, topSlice),
FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op);
// Paint the bottom edge.
if (drawBottom)
- graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
+ graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
destinationWidth, bottomWidth),
- LayoutRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
+ IntRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
FloatSize(bottomSideScale, bottomSideScale),
(Image::TileRule)hRule, Image::StretchTile, op);
@@ -1228,8 +1229,8 @@
middleScaleFactor.setHeight(destinationHeight / sourceHeight);
graphicsContext->drawTiledImage(image.get(), colorSpace,
- LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
- LayoutRect(leftSlice, topSlice, sourceWidth, sourceHeight),
+ IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
+ IntRect(leftSlice, topSlice, sourceWidth, sourceHeight),
middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op);
}
@@ -2346,7 +2347,7 @@
// This function relies on the fact we only get radii not contained within each edge if one of the radii
// for an edge is zero, so we can shift the arc towards the zero radius corner.
RoundedRect::Radii newRadii = innerBorder.radii();
- LayoutRect newRect = innerBorder.rect();
+ IntRect newRect = innerBorder.rect();
float overshoot;
float maxRadii;
@@ -2360,9 +2361,9 @@
if (!newRadii.topLeft().width())
newRect.move(-overshoot, 0);
}
- newRadii.setBottomLeft(LayoutSize(0, 0));
- newRadii.setBottomRight(LayoutSize(0, 0));
- maxRadii = max<LayoutUnit>(newRadii.topLeft().height(), newRadii.topRight().height());
+ newRadii.setBottomLeft(IntSize(0, 0));
+ newRadii.setBottomRight(IntSize(0, 0));
+ maxRadii = max(newRadii.topLeft().height(), newRadii.topRight().height());
if (maxRadii > newRect.height())
newRect.setHeight(maxRadii);
break;
@@ -2375,9 +2376,9 @@
if (!newRadii.bottomLeft().width())
newRect.move(-overshoot, 0);
}
- newRadii.setTopLeft(LayoutSize(0, 0));
- newRadii.setTopRight(LayoutSize(0, 0));
- maxRadii = max<LayoutUnit>(newRadii.bottomLeft().height(), newRadii.bottomRight().height());
+ newRadii.setTopLeft(IntSize(0, 0));
+ newRadii.setTopRight(IntSize(0, 0));
+ maxRadii = max(newRadii.bottomLeft().height(), newRadii.bottomRight().height());
if (maxRadii > newRect.height()) {
newRect.move(0, newRect.height() - maxRadii);
newRect.setHeight(maxRadii);
@@ -2392,9 +2393,9 @@
if (!newRadii.topLeft().height())
newRect.move(0, -overshoot);
}
- newRadii.setTopRight(LayoutSize(0, 0));
- newRadii.setBottomRight(LayoutSize(0, 0));
- maxRadii = max<LayoutUnit>(newRadii.topLeft().width(), newRadii.bottomLeft().width());
+ newRadii.setTopRight(IntSize(0, 0));
+ newRadii.setBottomRight(IntSize(0, 0));
+ maxRadii = max(newRadii.topLeft().width(), newRadii.bottomLeft().width());
if (maxRadii > newRect.width())
newRect.setWidth(maxRadii);
break;
@@ -2407,9 +2408,9 @@
if (!newRadii.topRight().height())
newRect.move(0, -overshoot);
}
- newRadii.setTopLeft(LayoutSize(0, 0));
- newRadii.setBottomLeft(LayoutSize(0, 0));
- maxRadii = max<LayoutUnit>(newRadii.topRight().width(), newRadii.bottomRight().width());
+ newRadii.setTopLeft(IntSize(0, 0));
+ newRadii.setBottomLeft(IntSize(0, 0));
+ maxRadii = max(newRadii.topRight().width(), newRadii.bottomRight().width());
if (maxRadii > newRect.width()) {
newRect.move(newRect.width() - maxRadii, 0);
newRect.setWidth(maxRadii);