Commit 4cac53aa authored by hyatt@apple.com's avatar hyatt@apple.com

2008-03-28 David Hyatt <hyatt@apple.com>

        Fix a bug where background-position truncates instead of rounding when it evaluates to fractional
        pixel values.  This matches other browsers.

        Reviewed by maciej

        Added fast/backgrounds/background-position-rounding.html

        * rendering/Length.h:
        (WebCore::Length::calcValue):
        (WebCore::Length::calcMinValue):
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::calculateBackgroundImageGeometry):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31389 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cb17bd09
2008-03-28 David Hyatt <hyatt@apple.com>
Fix a bug where background-position truncates instead of rounding when it evaluates to fractional
pixel values. This matches other browsers.
Reviewed by maciej
Added fast/backgrounds/background-position-rounding.html
* rendering/Length.h:
(WebCore::Length::calcValue):
(WebCore::Length::calcMinValue):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::calculateBackgroundImageGeometry):
2008-03-27 Kevin Ollivier <kevino@theolliviers.com>
wx build fix. Return a default value for operator ==
......@@ -103,12 +103,14 @@ namespace WebCore {
}
// note: works only for certain types, returns undefinedLength otherwise
int calcValue(int maxValue) const
int calcValue(int maxValue, bool roundPercentages = false) const
{
switch (type()) {
case Fixed:
return value();
case Percent:
if (roundPercentages)
return static_cast<int>(round(maxValue * percent()));
return maxValue * rawValue() / (100 * percentScaleFactor);
case Auto:
return maxValue;
......@@ -117,12 +119,14 @@ namespace WebCore {
}
}
int calcMinValue(int maxValue) const
int calcMinValue(int maxValue, bool roundPercentages = false) const
{
switch (type()) {
case Fixed:
return value();
case Percent:
if (roundPercentages)
return static_cast<int>(round(maxValue * percent()));
return maxValue * rawValue() / (100 * percentScaleFactor);
case Auto:
default:
......
......@@ -577,7 +577,7 @@ void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer,
EBackgroundRepeat backgroundRepeat = bgLayer->backgroundRepeat();
int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth, true);
if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_X) {
cw = pw + left + right;
sx = scaledImageWidth ? scaledImageWidth - (xPosition + left) % scaledImageWidth : 0;
......@@ -587,7 +587,7 @@ void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer,
cw = scaledImageWidth + min(xPosition + left, 0);
}
int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight, true);
if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_Y) {
ch = ph + top + bottom;
sy = scaledImageHeight ? scaledImageHeight - (yPosition + top) % scaledImageHeight : 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment