Add a more correct way to compare floating point numbers and use it
https://bugs.webkit.org/show_bug.cgi?id=138527

Reviewed by Darin Adler.

Source/WebCore:

Use the new WTF::areEssentuallyEqual() utility function from MathExtras.h
to compare floating-point numbers.

No new tests, no behavior change.

* page/DOMTimer.cpp:
(WebCore::DOMTimer::updateTimerIntervalIfNecessary):
* platform/graphics/FloatQuad.cpp:
(WebCore::FloatQuad::isRectilinear):
* platform/graphics/FloatRoundedRect.cpp:
(WebCore::FloatRoundedRect::Radii::isUniformCornerRadius):
* platform/graphics/FloatSize.h:
(WebCore::areEssentiallyEqual):
(WebCore::withinEpsilon): Deleted.

Source/WebKit/mac:

Use the new WTF::areEssentuallyEqual() utility function from MathExtras.h
to compare floating-point numbers.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _adjustedBottomOfPageWithTop:bottom:limit:]):

Source/WebKit2:

Use the new WTF::areEssentuallyEqual() utility function from MathExtras.h
to compare floating-point numbers.

* UIProcess/API/Cocoa/WKWebView.mm:
(withinEpsilon):
* UIProcess/CoordinatedGraphics/PageViewportController.cpp:
(WebKit::PageViewportController::updateMinimumScaleToFit):
(WebKit::fuzzyCompare): Deleted.
* UIProcess/CoordinatedGraphics/PageViewportController.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::withinEpsilon):

* UIProcess/API/Cocoa/WKWebView.mm:
(areEssentiallyEqualAsFloat):
(-[WKWebView _didCommitLayerTree:]):
(withinEpsilon): Deleted.
* UIProcess/CoordinatedGraphics/PageViewportController.cpp:
(WebKit::PageViewportController::updateMinimumScaleToFit):
(WebKit::fuzzyCompare): Deleted.
* UIProcess/CoordinatedGraphics/PageViewportController.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::areEssentialEqualAsFloat):
(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::withinEpsilon): Deleted.

Source/WTF:

To compare floating point numbers in the code base, we would often rely
on the following check:
std::abs(a - b) <= std::numeric_limits<T>::epsilon()

However, this is not correct for arbitrary floating point values, and
will fail for values that are not close to zero.

This patch introduces a WTF::areEssentiallyEqual() templated function
that can only be called with floating point types and relies on the
following formula from [1][2] that defines u as being "essentially
equal" to v if: | u - v | / |u| <= e and | u - v | / |v| <= e

[1] Knuth, D. E. "Accuracy of Floating Point Arithmetic." The Art of
    Computer Programming. 3rd ed. Vol. 2. Boston: Addison-Wesley, 1998.
    229-45.
[2] http://www.boost.org/doc/libs/1_34_0/libs/test/doc/components/test_tools/floating_point_comparison.html

* wtf/MathExtras.h:
(WTF::safeFPDivision):
(WTF::areEssentiallyEqual):
(WTF::withinEpsilon): Deleted.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175796 268f45cc-cd09-0410-ab3c-d52691b4dbfc