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

Side by Side Diff: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp

Issue 2132863002: IntersectionObserver: check threshold parameters for NaN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/IntersectionObserver.h" 5 #include "core/dom/IntersectionObserver.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/parser/CSSParserTokenRange.h" 8 #include "core/css/parser/CSSParserTokenRange.h"
9 #include "core/css/parser/CSSTokenizer.h" 9 #include "core/css/parser/CSSTokenizer.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void parseThresholds(const DoubleOrDoubleArray& thresholdParameter, Vector<float >& thresholds, ExceptionState& exceptionState) 105 void parseThresholds(const DoubleOrDoubleArray& thresholdParameter, Vector<float >& thresholds, ExceptionState& exceptionState)
106 { 106 {
107 if (thresholdParameter.isDouble()) { 107 if (thresholdParameter.isDouble()) {
108 thresholds.append(static_cast<float>(thresholdParameter.getAsDouble())); 108 thresholds.append(static_cast<float>(thresholdParameter.getAsDouble()));
109 } else { 109 } else {
110 for (auto thresholdValue : thresholdParameter.getAsDoubleArray()) 110 for (auto thresholdValue : thresholdParameter.getAsDoubleArray())
111 thresholds.append(static_cast<float>(thresholdValue)); 111 thresholds.append(static_cast<float>(thresholdValue));
112 } 112 }
113 113
114 for (auto thresholdValue : thresholds) { 114 for (auto thresholdValue : thresholds) {
115 if (thresholdValue < 0.0 || thresholdValue > 1.0) { 115 if (std::isnan(thresholdValue) || thresholdValue < 0.0 || thresholdValue > 1.0) {
116 exceptionState.throwRangeError("Threshold values must be between 0 a nd 1"); 116 exceptionState.throwRangeError("Threshold values must be numbers bet ween 0 and 1");
117 break; 117 break;
118 } 118 }
119 } 119 }
120 120
121 std::sort(thresholds.begin(), thresholds.end()); 121 std::sort(thresholds.begin(), thresholds.end());
122 } 122 }
123 123
124 // Returns the root Node of a given Document to use as the IntersectionObserver 124 // Returns the root Node of a given Document to use as the IntersectionObserver
125 // root when no root is given. 125 // root when no root is given.
126 // TODO(szager): it doesn't support RemoteFrames, see https://crbug.com/615156 126 // TODO(szager): it doesn't support RemoteFrames, see https://crbug.com/615156
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 405
406 DEFINE_TRACE(IntersectionObserver) 406 DEFINE_TRACE(IntersectionObserver)
407 { 407 {
408 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs erver::clearWeakMembers>(this); 408 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs erver::clearWeakMembers>(this);
409 visitor->trace(m_callback); 409 visitor->trace(m_callback);
410 visitor->trace(m_observations); 410 visitor->trace(m_observations);
411 visitor->trace(m_entries); 411 visitor->trace(m_entries);
412 } 412 }
413 413
414 } // namespace blink 414 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/intersection-observer/observer-exceptions-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698