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

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

Issue 2574773002: Migrate WTF::Vector::append() to ::push_back() [part 4 of N] (Closed)
Patch Set: rebase Created 4 years 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 // 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 while (tokenRange.peek().type() != EOFToken && 75 while (tokenRange.peek().type() != EOFToken &&
76 !exceptionState.hadException()) { 76 !exceptionState.hadException()) {
77 if (rootMargin.size() == 4) { 77 if (rootMargin.size() == 4) {
78 exceptionState.throwDOMException( 78 exceptionState.throwDOMException(
79 SyntaxError, "Extra text found at the end of rootMargin."); 79 SyntaxError, "Extra text found at the end of rootMargin.");
80 break; 80 break;
81 } 81 }
82 const CSSParserToken& token = tokenRange.consumeIncludingWhitespace(); 82 const CSSParserToken& token = tokenRange.consumeIncludingWhitespace();
83 switch (token.type()) { 83 switch (token.type()) {
84 case PercentageToken: 84 case PercentageToken:
85 rootMargin.append(Length(token.numericValue(), Percent)); 85 rootMargin.push_back(Length(token.numericValue(), Percent));
86 break; 86 break;
87 case DimensionToken: 87 case DimensionToken:
88 switch (token.unitType()) { 88 switch (token.unitType()) {
89 case CSSPrimitiveValue::UnitType::Pixels: 89 case CSSPrimitiveValue::UnitType::Pixels:
90 rootMargin.append( 90 rootMargin.push_back(
91 Length(static_cast<int>(floor(token.numericValue())), Fixed)); 91 Length(static_cast<int>(floor(token.numericValue())), Fixed));
92 break; 92 break;
93 case CSSPrimitiveValue::UnitType::Percentage: 93 case CSSPrimitiveValue::UnitType::Percentage:
94 rootMargin.append(Length(token.numericValue(), Percent)); 94 rootMargin.push_back(Length(token.numericValue(), Percent));
95 break; 95 break;
96 default: 96 default:
97 exceptionState.throwDOMException( 97 exceptionState.throwDOMException(
98 SyntaxError, 98 SyntaxError,
99 "rootMargin must be specified in pixels or percent."); 99 "rootMargin must be specified in pixels or percent.");
100 } 100 }
101 break; 101 break;
102 default: 102 default:
103 exceptionState.throwDOMException( 103 exceptionState.throwDOMException(
104 SyntaxError, "rootMargin must be specified in pixels or percent."); 104 SyntaxError, "rootMargin must be specified in pixels or percent.");
105 } 105 }
106 } 106 }
107 } 107 }
108 108
109 void parseThresholds(const DoubleOrDoubleSequence& thresholdParameter, 109 void parseThresholds(const DoubleOrDoubleSequence& thresholdParameter,
110 Vector<float>& thresholds, 110 Vector<float>& thresholds,
111 ExceptionState& exceptionState) { 111 ExceptionState& exceptionState) {
112 if (thresholdParameter.isDouble()) { 112 if (thresholdParameter.isDouble()) {
113 thresholds.append(static_cast<float>(thresholdParameter.getAsDouble())); 113 thresholds.push_back(static_cast<float>(thresholdParameter.getAsDouble()));
114 } else { 114 } else {
115 for (auto thresholdValue : thresholdParameter.getAsDoubleSequence()) 115 for (auto thresholdValue : thresholdParameter.getAsDoubleSequence())
116 thresholds.append(static_cast<float>(thresholdValue)); 116 thresholds.push_back(static_cast<float>(thresholdValue));
117 } 117 }
118 118
119 for (auto thresholdValue : thresholds) { 119 for (auto thresholdValue : thresholds) {
120 if (std::isnan(thresholdValue) || thresholdValue < 0.0 || 120 if (std::isnan(thresholdValue) || thresholdValue < 0.0 ||
121 thresholdValue > 1.0) { 121 thresholdValue > 1.0) {
122 exceptionState.throwRangeError( 122 exceptionState.throwRangeError(
123 "Threshold values must be numbers between 0 and 1"); 123 "Threshold values must be numbers between 0 and 1");
124 break; 124 break;
125 } 125 }
126 } 126 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 appendLength(stringBuilder, m_rightMargin); 376 appendLength(stringBuilder, m_rightMargin);
377 stringBuilder.append(' '); 377 stringBuilder.append(' ');
378 appendLength(stringBuilder, m_bottomMargin); 378 appendLength(stringBuilder, m_bottomMargin);
379 stringBuilder.append(' '); 379 stringBuilder.append(' ');
380 appendLength(stringBuilder, m_leftMargin); 380 appendLength(stringBuilder, m_leftMargin);
381 return stringBuilder.toString(); 381 return stringBuilder.toString();
382 } 382 }
383 383
384 void IntersectionObserver::enqueueIntersectionObserverEntry( 384 void IntersectionObserver::enqueueIntersectionObserverEntry(
385 IntersectionObserverEntry& entry) { 385 IntersectionObserverEntry& entry) {
386 m_entries.append(&entry); 386 m_entries.push_back(&entry);
387 toDocument(m_callback->getExecutionContext()) 387 toDocument(m_callback->getExecutionContext())
388 ->ensureIntersectionObserverController() 388 ->ensureIntersectionObserverController()
389 .scheduleIntersectionObserverForDelivery(*this); 389 .scheduleIntersectionObserverForDelivery(*this);
390 } 390 }
391 391
392 unsigned IntersectionObserver::firstThresholdGreaterThan(float ratio) const { 392 unsigned IntersectionObserver::firstThresholdGreaterThan(float ratio) const {
393 unsigned result = 0; 393 unsigned result = 0;
394 while (result < m_thresholds.size() && m_thresholds[result] <= ratio) 394 while (result < m_thresholds.size() && m_thresholds[result] <= ratio)
395 ++result; 395 ++result;
396 return result; 396 return result;
(...skipping 10 matching lines...) Expand all
407 407
408 DEFINE_TRACE(IntersectionObserver) { 408 DEFINE_TRACE(IntersectionObserver) {
409 visitor->template registerWeakMembers< 409 visitor->template registerWeakMembers<
410 IntersectionObserver, &IntersectionObserver::clearWeakMembers>(this); 410 IntersectionObserver, &IntersectionObserver::clearWeakMembers>(this);
411 visitor->trace(m_callback); 411 visitor->trace(m_callback);
412 visitor->trace(m_observations); 412 visitor->trace(m_observations);
413 visitor->trace(m_entries); 413 visitor->trace(m_entries);
414 } 414 }
415 415
416 } // namespace blink 416 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698