From: leviw@chromium.org Date: Wed, 22 Feb 2012 20:57:43 +0000 (+0000) Subject: ScrollbarThemeComposite::thumbPosition uses the result of a divide by zero X-Git-Tag: 070512121124~12122 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33e6052d449db27423f25d1090a241f53cc2cabc;p=profile%2Fivi%2Fwebkit-efl.git 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108541 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ed47482..22e18cf 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2012-02-22 Levi Weintraub + + 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 Have the DynamicsCompressorNode support multi-channel data diff --git a/Source/WebCore/platform/ScrollbarThemeComposite.cpp b/Source/WebCore/platform/ScrollbarThemeComposite.cpp index fcbf484..62fd5e5 100644 --- a/Source/WebCore/platform/ScrollbarThemeComposite.cpp +++ b/Source/WebCore/platform/ScrollbarThemeComposite.cpp @@ -226,7 +226,11 @@ static float usedTotalSize(Scrollbar* scrollbar) 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;