Changeset 175655 in webkit
- Timestamp:
- Nov 5, 2014, 6:21:14 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r175648 r175655 1 2014-11-05 Chris Dumez <cdumez@apple.com> 2 3 Assertion hit DOMTimer::updateTimerIntervalIfNecessary() 4 https://bugs.webkit.org/show_bug.cgi?id=138440 5 6 Reviewed by Geoffrey Garen. 7 8 Move the withinEpsilon() function to WTF to avoid code duplication. 9 10 * wtf/MathExtras.h: 11 (WTF::withinEpsilon): 12 1 13 2014-11-05 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Source/WTF/wtf/MathExtras.h
r175261 r175655 393 393 } 394 394 395 template <typename T> 396 inline bool withinEpsilon(T a, T b) 397 { 398 return std::abs(a - b) <= std::numeric_limits<T>::epsilon(); 399 } 400 395 401 } // namespace WTF 396 402 -
trunk/Source/WebCore/ChangeLog
r175654 r175655 1 2014-11-05 Chris Dumez <cdumez@apple.com> 2 3 Assertion hit DOMTimer::updateTimerIntervalIfNecessary() 4 https://bugs.webkit.org/show_bug.cgi?id=138440 5 6 Reviewed by Geoffrey Garen. 7 8 We sometimes hit the ASSERT(repeatInterval() == previousInterval) 9 assertion in DOMTimer::updateTimerIntervalIfNecessary() when visiting 10 the following pages: 11 http://lifehacker.com/the-healthiest-foods-for-one-handed-snacking-while-gami-1654728164 12 http://longform.org/posts/like-something-the-lord-made 13 14 After debugging, the issue turned out to be that we are comparing 15 floating point numbers using ==, and the check sometimes fails even 16 though the values really close to each other. This patch updates the 17 DOMTimer code to use WTF::withinEpsilon() instead of operator==() 18 to compare the floating point intervals. 19 20 I confirmed manually that the assertion is no longer hit. 21 22 * page/DOMTimer.cpp: 23 (WebCore::DOMTimer::updateTimerIntervalIfNecessary): 24 * platform/graphics/FloatQuad.cpp: 25 (WebCore::FloatQuad::isRectilinear): 26 (WebCore::withinEpsilon): Deleted. 27 1 28 2014-11-05 Chris Fleizach <cfleizach@apple.com> 2 29 -
trunk/Source/WebCore/page/DOMTimer.cpp
r175627 r175655 36 36 #include <wtf/CurrentTime.h> 37 37 #include <wtf/HashSet.h> 38 #include <wtf/MathExtras.h> 38 39 #include <wtf/StdLibExtras.h> 39 40 … … 318 319 m_currentTimerInterval = intervalClampedToMinimum(); 319 320 320 if ( previousInterval == m_currentTimerInterval)321 if (WTF::withinEpsilon(previousInterval, m_currentTimerInterval)) 321 322 return; 322 323 323 324 if (repeatInterval()) { 324 ASSERT( repeatInterval() == previousInterval);325 ASSERT(WTF::withinEpsilon(repeatInterval(), previousInterval)); 325 326 augmentRepeatInterval(m_currentTimerInterval - previousInterval); 326 327 } else -
trunk/Source/WebCore/platform/graphics/FloatQuad.cpp
r165676 r175655 34 34 #include <algorithm> 35 35 #include <limits> 36 #include <wtf/MathExtras.h> 36 37 37 38 namespace WebCore { … … 91 92 } 92 93 93 static inline bool withinEpsilon(float a, float b)94 {95 return fabs(a - b) < std::numeric_limits<float>::epsilon();96 }97 98 94 bool FloatQuad::isRectilinear() const 99 95 { 100 return ( withinEpsilon(m_p1.x(), m_p2.x()) && withinEpsilon(m_p2.y(), m_p3.y()) && withinEpsilon(m_p3.x(), m_p4.x()) &&withinEpsilon(m_p4.y(), m_p1.y()))101 || ( withinEpsilon(m_p1.y(), m_p2.y()) && withinEpsilon(m_p2.x(), m_p3.x()) && withinEpsilon(m_p3.y(), m_p4.y()) &&withinEpsilon(m_p4.x(), m_p1.x()));96 return (WTF::withinEpsilon(m_p1.x(), m_p2.x()) && WTF::withinEpsilon(m_p2.y(), m_p3.y()) && WTF::withinEpsilon(m_p3.x(), m_p4.x()) && WTF::withinEpsilon(m_p4.y(), m_p1.y())) 97 || (WTF::withinEpsilon(m_p1.y(), m_p2.y()) && WTF::withinEpsilon(m_p2.x(), m_p3.x()) && WTF::withinEpsilon(m_p3.y(), m_p4.y()) && WTF::withinEpsilon(m_p4.x(), m_p1.x())); 102 98 } 103 99
Note:
See TracChangeset
for help on using the changeset viewer.