RESOLVED FIXED Bug 93475
Floored and truncated rounding confused
https://bugs.webkit.org/show_bug.cgi?id=93475
Summary Floored and truncated rounding confused
Allan Sandfeld Jensen
Reported 2012-08-08 07:00:24 PDT
The two rounding forms floor and truncate are mixed up in several places in the code, mostly in the subpixel layout code, but also in flooredIntPoint(FloatPoint). For most cases this is not a problem since truncate and floor are identical for positive numbers, they only differ for negative numbers, which are not as nearly as common in the WebCore layout code. This bug currently only leads to minor pixel differences with subpixel layout enabled, but the fix for bug #23170 depends on it both with and without subpixel layout enabled.
Attachments
Patch (17.82 KB, patch)
2012-08-08 07:11 PDT, Allan Sandfeld Jensen
no flags
Allan Sandfeld Jensen
Comment 1 2012-08-08 07:11:23 PDT
Levi Weintraub
Comment 2 2012-08-08 10:45:54 PDT
Comment on attachment 157211 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157211&action=review > Source/WebCore/ChangeLog:12 > + This patch changes several instances of floored rounding to do actual floored > + rounding, and a fixes and cleans up several places using floored rounding. What are you saying this changes? I'm not sure what "actual" means here. > Source/WebCore/platform/graphics/FractionalLayoutRect.cpp:134 > - float x = floorf(rect.x().toFloat()); > - float y = floorf(rect.y().toFloat()); > - float width = ceilf(rect.maxX().toFloat()) - x; > - float height = ceilf(rect.maxY().toFloat()) - y; > + IntPoint location = flooredIntPoint(rect.minXMinYCorner()); > + IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner()); > > - return IntRect(clampToInteger(x), clampToInteger(y), > - clampToInteger(width), clampToInteger(height)); > + return IntRect(location, maxPoint - location); So much cleaner, well done! > Source/WebCore/rendering/RenderReplaced.cpp:291 > - m_intrinsicSize = flooredIntSize(intrinsicSize); // FIXME: This introduces precision errors. We should convert m_intrinsicSize to be a float. > + m_intrinsicSize = IntSize(intrinsicSize.width(), intrinsicSize.height()); // FIXME: This introduces precision errors. We should convert m_intrinsicSize to be a float. Why this change is correct isn't obvious to me. Since intrinsic size is never negative this doesn't seem to change any behavior. How about an explanation in the changelog?
Allan Sandfeld Jensen
Comment 3 2012-08-08 11:30:53 PDT
(In reply to comment #2) > (From update of attachment 157211 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=157211&action=review > > > Source/WebCore/ChangeLog:12 > > + This patch changes several instances of floored rounding to do actual floored > > + rounding, and a fixes and cleans up several places using floored rounding. > > What are you saying this changes? I'm not sure what "actual" means here. > That is not clear I agree. I will remove 'actual' and instead explain that some floor operations were previously doing rounding towards zero, when they should be rounding down (away from zero for negative numbers). > > Source/WebCore/rendering/RenderReplaced.cpp:291 > > - m_intrinsicSize = flooredIntSize(intrinsicSize); // FIXME: This introduces precision errors. We should convert m_intrinsicSize to be a float. > > + m_intrinsicSize = IntSize(intrinsicSize.width(), intrinsicSize.height()); // FIXME: This introduces precision errors. We should convert m_intrinsicSize to be a float. > > Why this change is correct isn't obvious to me. Since intrinsic size is never negative this doesn't seem to change any behavior. How about an explanation in the changelog? You are right, I should have left that unchanged. I was at one point considering removing all uses of flooredIntSize (around 3), but decided to not to include that in this patch. I guess I forgot to revert this change.
Allan Sandfeld Jensen
Comment 4 2012-08-09 05:20:48 PDT
Levi Weintraub
Comment 5 2012-08-09 10:10:09 PDT
Comment on attachment 157211 [details] Patch Clearing flags.
Note You need to log in before you can comment on or make changes to this bug.