[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/khtml/css
From: Maks Orlovich <maksim () kde ! org>
Date: 2010-10-07 15:42:15
Message-ID: 20101007154215.C5230AC892 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1183493 by orlovich:
Fix rounding issues with border sizes
BUG: 252280
M +1 -5 css_valueimpl.cpp
M +10 -0 css_valueimpl.h
M +1 -1 cssstyleselector.cpp
--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #1183492:1183493
@@ -1052,11 +1052,7 @@
int CSSPrimitiveValueImpl::computeLength( khtml::RenderStyle *style, int logicalDpiY)
{
- double result = computeLengthFloat( style, logicalDpiY );
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- int intResult = (int)(result + (result < 0 ? -0.01 : +0.01));
- return intResult;
+ return snapValue( computeLengthFloat( style, logicalDpiY ) );
}
double CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, int logicalDpiY)
--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.h #1183492:1183493
@@ -222,6 +222,16 @@
double computeLengthFloat( khtml::RenderStyle *style, int logicalDpiY);
+ /*
+ * rounds a computer value into integer as appropriate. This takes
+ * care of the various 4.9999999999 type cases
+ */
+ static int snapValue( double result ) {
+ // Conversions are imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ return (int)(result + (result < 0 ? -0.01 : +0.01));
+ }
+
// Retrieves an explicit resolution from the CSSValue if it contains one.
// This is specific to the CSS3 Media Queries module's resolution feature.
int getDPIResolution() const;
--- trunk/KDE/kdelibs/khtml/css/cssstyleselector.cpp #1183492:1183493
@@ -3073,7 +3073,7 @@
case CSS_VAL_INVALID:
{
double widthd = primitiveValue->computeLengthFloat(style, logicalDpiY);
- width = (int)widthd;
+ width = CSSPrimitiveValueImpl::snapValue(widthd);
// somewhat resemble Mozilla's granularity
// this makes border-width: 0.5pt borders visible
if (width == 0 && widthd >= 0.025) width++;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic