LayoutTests/ChangeLog

 12011-02-24 David Grogan <dgrogan@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4 Make WebCore::CSSPrimitiveValue::computeLengthDouble round, rather
 5 than truncate, lengths specified in units other than pixels.
 6 https://bugs.webkit.org/show_bug.cgi?id=22759
 7
 8 * css1/units/rounding-expected.txt: Added.
 9 * css1/units/rounding.html: Added.
 10
1112011-02-25 Mihai Parparita <mihaip@chromium.org>
212
313 Unreviewed Chromium expectations update.

LayoutTests/css1/units/rounding-expected.txt

 1no gap below
 2no gap above
 3This test checks that floating point rounding doesn't cause misalignment. There should be no gap between the divs.
 4
 5On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 6
 7PASS divtop.bottom is 31
 8PASS divbottom.top is 31
 9PASS successfullyParsed is true
 10
 11TEST COMPLETE
 12

LayoutTests/css1/units/rounding.html

 1<html>
 2<head>
 3<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"/>
 4<style type="text/css">
 5 body, div {
 6 margin: 0;
 7 padding: 0;
 8 border: 0;
 9 }
 10 #top, #bottom {
 11 line-height: 1.5;
 12 font-size: 70%;
 13 background:green;
 14 color:white;
 15 width:100%;
 16 }
 17 #top {
 18 padding:.6em 0 .7em;
 19 }
 20 #bottom {
 21 position:absolute;
 22 top:2.8em;
 23 }
 24</style>
 25</head>
 26<body>
 27
 28<div id="top">no gap below</div>
 29<div id="bottom">no gap above</div>
 30
 31<div id="description"></div>
 32<div id="console"></div>
 33<script src="../../fast/js/resources/js-test-pre.js"></script>
 34<script>
 35
 36description("This test checks that floating point rounding doesn't cause misalignment. There should be no gap between the divs.");
 37
 38var divtop = document.getElementById("top").getBoundingClientRect();
 39var divbottom = document.getElementById("bottom").getBoundingClientRect();
 40shouldBe('divtop.bottom', '31');
 41shouldBe('divbottom.top', '31');
 42
 43successfullyParsed = true;
 44</script>
 45
 46<script src="../../fast/js/resources/js-test-post.js"></script>
 47
 48</body>
 49</html>

Source/WebCore/ChangeLog

 12011-02-24 David Grogan <dgrogan@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Make WebCore::CSSPrimitiveValue::computeLengthDouble round, rather
 6 than truncate, lengths specified in units other than pixels.
 7 https://bugs.webkit.org/show_bug.cgi?id=22759
 8
 9 Test: css1/units/rounding.html
 10
 11 * css/CSSPrimitiveValue.cpp:
 12 (WebCore::CSSPrimitiveValue::computeLengthDouble):
 13
1142011-02-25 David Hyatt <hyatt@apple.com>
215
316 Reviewed by Sam Weinig.

Source/WebCore/css/CSSPrimitiveValue.cpp

3434#include "RGBColor.h"
3535#include "Rect.h"
3636#include "RenderStyle.h"
 37#include <math.h>
3738#include <wtf/ASCIICType.h>
3839#include <wtf/DecimalNumber.h>
3940#include <wtf/MathExtras.h>

@@double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* r
398399 // as well as enforcing the implicit "smart minimum." In addition the CSS property text-size-adjust is used to
399400 // prevent text from zooming at all. Therefore we will not apply the zoom here if we are computing font-size.
400401 bool applyZoomMultiplier = !computingFontSize;
 402 bool shouldRound = true;
401403
402404 double factor = 1.0;
403405 switch (type) {

@@double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* r
417419 factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize();
418420 break;
419421 case CSS_PX:
 422 shouldRound = false;
420423 break;
421424 case CSS_CM:
422425 factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)

@@double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* r
440443
441444 double result = getDoubleValue() * factor;
442445 if (!applyZoomMultiplier || multiplier == 1.0)
443  return result;
444 
 446 return shouldRound ? round(result) : result;
 447
445448 // Any original result that was >= 1 should not be allowed to fall below 1. This keeps border lines from
446449 // vanishing.
447450 double zoomedResult = result * multiplier;