Title: [108541] trunk/Source/WebCore
Revision
108541
Author
[email protected]
Date
2012-02-22 12:57:43 -0800 (Wed, 22 Feb 2012)

Log Message

ScrollbarThemeComposite::thumbPosition uses the result of a divide by zero
https://bugs.webkit.org/show_bug.cgi?id=78910

Reviewed by Eric Seidel.

Adding a check to avoid doing a floating point divide by zero and assigning NaN to an integer.
This causes problems with our conversion to subpixel layout, which asserts when we overflow.

* platform/ScrollbarThemeComposite.cpp:
(WebCore::ScrollbarThemeComposite::thumbPosition):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108540 => 108541)


--- trunk/Source/WebCore/ChangeLog	2012-02-22 20:51:32 UTC (rev 108540)
+++ trunk/Source/WebCore/ChangeLog	2012-02-22 20:57:43 UTC (rev 108541)
@@ -1,3 +1,16 @@
+2012-02-22  Levi Weintraub  <[email protected]>
+
+        ScrollbarThemeComposite::thumbPosition uses the result of a divide by zero
+        https://bugs.webkit.org/show_bug.cgi?id=78910
+
+        Reviewed by Eric Seidel.
+
+        Adding a check to avoid doing a floating point divide by zero and assigning NaN to an integer.
+        This causes problems with our conversion to subpixel layout, which asserts when we overflow.
+
+        * platform/ScrollbarThemeComposite.cpp:
+        (WebCore::ScrollbarThemeComposite::thumbPosition):
+
 2012-02-22  Raymond Liu  <[email protected]>
 
         Have the DynamicsCompressorNode support multi-channel data

Modified: trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp (108540 => 108541)


--- trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp	2012-02-22 20:51:32 UTC (rev 108540)
+++ trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp	2012-02-22 20:57:43 UTC (rev 108541)
@@ -226,7 +226,11 @@
 int ScrollbarThemeComposite::thumbPosition(Scrollbar* scrollbar)
 {
     if (scrollbar->enabled()) {
-        float pos = max(0.0f, scrollbar->currentPos()) * (trackLength(scrollbar) - thumbLength(scrollbar)) / (usedTotalSize(scrollbar) - scrollbar->visibleSize());
+        float size = usedTotalSize(scrollbar) - scrollbar->visibleSize();
+        // Avoid doing a floating point divide by zero and return 1 when usedTotalSize == visibleSize.
+        if (!size)
+            return 1;
+        float pos = max(0.0f, scrollbar->currentPos()) * (trackLength(scrollbar) - thumbLength(scrollbar)) / size;
         return (pos < 1 && pos > 0) ? 1 : pos;
     }
     return 0;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to