Title: [123626] trunk/Source/WebCore
- Revision
- 123626
- Author
- [email protected]
- Date
- 2012-07-25 09:45:17 -0700 (Wed, 25 Jul 2012)
Log Message
Incorrect rounding in ceiledLayoutUnit and roundedLayoutUnit.
https://bugs.webkit.org/show_bug.cgi?id=91061
Reviewed by Adam Barth.
The two functions are currently both returning the flooredLayoutUnit when subpixel
layout is enabled. This patch changes them to return the correct fractional rounded
value.
* platform/FractionalLayoutUnit.h:
(WebCore::FractionalLayoutUnit::fromFloatCeil):
(FractionalLayoutUnit):
(WebCore::FractionalLayoutUnit::fromFloatRound):
* rendering/LayoutTypes.h:
(WebCore::roundedLayoutUnit):
(WebCore::ceiledLayoutUnit):
* rendering/RenderBlock.cpp:
(WebCore::updatePreferredWidth):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (123625 => 123626)
--- trunk/Source/WebCore/ChangeLog 2012-07-25 16:13:52 UTC (rev 123625)
+++ trunk/Source/WebCore/ChangeLog 2012-07-25 16:45:17 UTC (rev 123626)
@@ -1,3 +1,24 @@
+2012-07-25 Allan Sandfeld Jensen <[email protected]>
+
+ Incorrect rounding in ceiledLayoutUnit and roundedLayoutUnit.
+ https://bugs.webkit.org/show_bug.cgi?id=91061
+
+ Reviewed by Adam Barth.
+
+ The two functions are currently both returning the flooredLayoutUnit when subpixel
+ layout is enabled. This patch changes them to return the correct fractional rounded
+ value.
+
+ * platform/FractionalLayoutUnit.h:
+ (WebCore::FractionalLayoutUnit::fromFloatCeil):
+ (FractionalLayoutUnit):
+ (WebCore::FractionalLayoutUnit::fromFloatRound):
+ * rendering/LayoutTypes.h:
+ (WebCore::roundedLayoutUnit):
+ (WebCore::ceiledLayoutUnit):
+ * rendering/RenderBlock.cpp:
+ (WebCore::updatePreferredWidth):
+
2012-07-25 Gyuyoung Kim <[email protected]>
Add *explicit* keyword to constructors in WebCore/platform
Modified: trunk/Source/WebCore/platform/FractionalLayoutUnit.h (123625 => 123626)
--- trunk/Source/WebCore/platform/FractionalLayoutUnit.h 2012-07-25 16:13:52 UTC (rev 123625)
+++ trunk/Source/WebCore/platform/FractionalLayoutUnit.h 2012-07-25 16:45:17 UTC (rev 123626)
@@ -88,12 +88,19 @@
static FractionalLayoutUnit fromFloatCeil(float value)
{
- REPORT_OVERFLOW(isInBounds(value));
- FractionalLayoutUnit v;
- v.m_value = ceilf(value * kFixedPointDenominator);
- return v;
+ REPORT_OVERFLOW(isInBounds(value));
+ FractionalLayoutUnit v;
+ v.m_value = ceilf(value * kFixedPointDenominator);
+ return v;
}
+ static FractionalLayoutUnit fromFloatRound(float value)
+ {
+ if (value >= 0)
+ return FractionalLayoutUnit(value + epsilon() / 2.0f);
+ return FractionalLayoutUnit(value - epsilon() / 2.0f);
+ }
+
#if ENABLE(SUBPIXEL_LAYOUT)
int toInt() const { return m_value / kFixedPointDenominator; }
float toFloat() const { return static_cast<float>(m_value) / kFixedPointDenominator; }
Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (123625 => 123626)
--- trunk/Source/WebCore/rendering/LayoutTypes.h 2012-07-25 16:13:52 UTC (rev 123625)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h 2012-07-25 16:45:17 UTC (rev 123626)
@@ -117,7 +117,7 @@
inline LayoutUnit roundedLayoutUnit(float value)
{
#if ENABLE(SUBPIXEL_LAYOUT)
- return FractionalLayoutUnit(value);
+ return FractionalLayoutUnit::fromFloatRound(value);
#else
return static_cast<int>(lroundf(value));
#endif
@@ -126,7 +126,7 @@
inline LayoutUnit ceiledLayoutUnit(float value)
{
#if ENABLE(SUBPIXEL_LAYOUT)
- return FractionalLayoutUnit(value);
+ return FractionalLayoutUnit::fromFloatCeil(value);
#else
return ceilf(value);
#endif
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (123625 => 123626)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-07-25 16:13:52 UTC (rev 123625)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-07-25 16:45:17 UTC (rev 123626)
@@ -5593,7 +5593,7 @@
static inline void updatePreferredWidth(LayoutUnit& preferredWidth, float& result)
{
- LayoutUnit snappedResult = LayoutUnit::fromFloatCeil(result);
+ LayoutUnit snappedResult = ceiledLayoutUnit(result);
preferredWidth = max(snappedResult, preferredWidth);
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes