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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108541
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-22 Levi Weintraub <leviw@chromium.org>
+
+ 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 <raymond.liu@intel.com>
Have the DynamicsCompressorNode support multi-channel data
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;