Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXProgressIndicator.cpp

Issue 2342913003: Replace narrowPrecisionToFloat with clampTo<float> (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 * 18 *
19 */ 19 */
20 20
21 #include "modules/accessibility/AXProgressIndicator.h" 21 #include "modules/accessibility/AXProgressIndicator.h"
22 22
23 #include "core/html/HTMLProgressElement.h" 23 #include "core/html/HTMLProgressElement.h"
24 #include "core/layout/LayoutProgress.h" 24 #include "core/layout/LayoutProgress.h"
25 #include "modules/accessibility/AXObjectCacheImpl.h" 25 #include "modules/accessibility/AXObjectCacheImpl.h"
26 #include "platform/FloatConversion.h" 26 #include "wtf/MathExtras.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 using namespace HTMLNames; 30 using namespace HTMLNames;
31 31
32 AXProgressIndicator::AXProgressIndicator(LayoutProgress* layoutObject, AXObjectC acheImpl& axObjectCache) 32 AXProgressIndicator::AXProgressIndicator(LayoutProgress* layoutObject, AXObjectC acheImpl& axObjectCache)
33 : AXLayoutObject(layoutObject, axObjectCache) 33 : AXLayoutObject(layoutObject, axObjectCache)
34 { 34 {
35 } 35 }
36 36
(...skipping 13 matching lines...) Expand all
50 { 50 {
51 return accessibilityIsIgnoredByDefault(ignoredReasons); 51 return accessibilityIsIgnoredByDefault(ignoredReasons);
52 } 52 }
53 53
54 float AXProgressIndicator::valueForRange() const 54 float AXProgressIndicator::valueForRange() const
55 { 55 {
56 if (hasAttribute(aria_valuenowAttr)) 56 if (hasAttribute(aria_valuenowAttr))
57 return getAttribute(aria_valuenowAttr).toFloat(); 57 return getAttribute(aria_valuenowAttr).toFloat();
58 58
59 if (element()->position() >= 0) 59 if (element()->position() >= 0)
60 return narrowPrecisionToFloat(element()->value()); 60 return clampTo<float>(element()->value());
61 // Indeterminate progress bar should return 0. 61 // Indeterminate progress bar should return 0.
62 return 0.0f; 62 return 0.0f;
63 } 63 }
64 64
65 float AXProgressIndicator::maxValueForRange() const 65 float AXProgressIndicator::maxValueForRange() const
66 { 66 {
67 if (hasAttribute(aria_valuemaxAttr)) 67 if (hasAttribute(aria_valuemaxAttr))
68 return getAttribute(aria_valuemaxAttr).toFloat(); 68 return getAttribute(aria_valuemaxAttr).toFloat();
69 69
70 return narrowPrecisionToFloat(element()->max()); 70 return clampTo<float>(element()->max());
71 } 71 }
72 72
73 float AXProgressIndicator::minValueForRange() const 73 float AXProgressIndicator::minValueForRange() const
74 { 74 {
75 if (hasAttribute(aria_valueminAttr)) 75 if (hasAttribute(aria_valueminAttr))
76 return getAttribute(aria_valueminAttr).toFloat(); 76 return getAttribute(aria_valueminAttr).toFloat();
77 77
78 return 0.0f; 78 return 0.0f;
79 } 79 }
80 80
81 HTMLProgressElement* AXProgressIndicator::element() const 81 HTMLProgressElement* AXProgressIndicator::element() const
82 { 82 {
83 return toLayoutProgress(m_layoutObject)->progressElement(); 83 return toLayoutProgress(m_layoutObject)->progressElement();
84 } 84 }
85 85
86 86
87 } // namespace blink 87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698