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

Side by Side Diff: third_party/WebKit/Source/core/html/TimeRanges.cpp

Issue 2258033002: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. Created 4 years, 4 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) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 double end = m_ranges.last().m_end; 79 double end = m_ranges.last().m_end;
80 if (end != posInf) 80 if (end != posInf)
81 inverted->add(end, posInf); 81 inverted->add(end, posInf);
82 } 82 }
83 83
84 m_ranges.swap(inverted->m_ranges); 84 m_ranges.swap(inverted->m_ranges);
85 } 85 }
86 86
87 void TimeRanges::intersectWith(const TimeRanges* other) 87 void TimeRanges::intersectWith(const TimeRanges* other)
88 { 88 {
89 ASSERT(other); 89 DCHECK(other);
90 90
91 if (other == this) 91 if (other == this)
92 return; 92 return;
93 93
94 TimeRanges* invertedOther = other->copy(); 94 TimeRanges* invertedOther = other->copy();
95 invertedOther->invert(); 95 invertedOther->invert();
96 96
97 invert(); 97 invert();
98 unionWith(invertedOther); 98 unionWith(invertedOther);
99 invert(); 99 invert();
100 } 100 }
101 101
102 void TimeRanges::unionWith(const TimeRanges* other) 102 void TimeRanges::unionWith(const TimeRanges* other)
103 { 103 {
104 ASSERT(other); 104 DCHECK(other);
105 TimeRanges* unioned = copy(); 105 TimeRanges* unioned = copy();
106 for (size_t index = 0; index < other->m_ranges.size(); ++index) { 106 for (size_t index = 0; index < other->m_ranges.size(); ++index) {
107 const Range& range = other->m_ranges[index]; 107 const Range& range = other->m_ranges[index];
108 unioned->add(range.m_start, range.m_end); 108 unioned->add(range.m_start, range.m_end);
109 } 109 }
110 110
111 m_ranges.swap(unioned->m_ranges); 111 m_ranges.swap(unioned->m_ranges);
112 } 112 }
113 113
114 double TimeRanges::start(unsigned index, ExceptionState& exceptionState) const 114 double TimeRanges::start(unsigned index, ExceptionState& exceptionState) const
115 { 115 {
116 if (index >= length()) { 116 if (index >= length()) {
117 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("index", index, length())); 117 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("index", index, length()));
118 return 0; 118 return 0;
119 } 119 }
120 return m_ranges[index].m_start; 120 return m_ranges[index].m_start;
121 } 121 }
122 122
123 double TimeRanges::end(unsigned index, ExceptionState& exceptionState) const 123 double TimeRanges::end(unsigned index, ExceptionState& exceptionState) const
124 { 124 {
125 if (index >= length()) { 125 if (index >= length()) {
126 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("index", index, length())); 126 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("index", index, length()));
127 return 0; 127 return 0;
128 } 128 }
129 return m_ranges[index].m_end; 129 return m_ranges[index].m_end;
130 } 130 }
131 131
132 void TimeRanges::add(double start, double end) 132 void TimeRanges::add(double start, double end)
133 { 133 {
134 ASSERT(start <= end); 134 DCHECK_LE(start, end);
135 unsigned overlappingArcIndex; 135 unsigned overlappingArcIndex;
136 Range addedRange(start, end); 136 Range addedRange(start, end);
137 137
138 // For each present range check if we need to: 138 // For each present range check if we need to:
139 // - merge with the added range, in case we are overlapping or contiguous 139 // - merge with the added range, in case we are overlapping or contiguous
140 // - Need to insert in place, we we are completely, not overlapping and not contiguous 140 // - Need to insert in place, we we are completely, not overlapping and not contiguous
141 // in between two ranges. 141 // in between two ranges.
142 // 142 //
143 // TODO: Given that we assume that ranges are correctly ordered, this could be optimized. 143 // TODO: Given that we assume that ranges are correctly ordered, this could be optimized.
144 144
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 if (delta < bestDelta || (delta == bestDelta 204 if (delta < bestDelta || (delta == bestDelta
205 && std::abs(currentPlaybackPosition - match) < std::abs(currentPlayb ackPosition - bestMatch))) { 205 && std::abs(currentPlaybackPosition - match) < std::abs(currentPlayb ackPosition - bestMatch))) {
206 bestDelta = delta; 206 bestDelta = delta;
207 bestMatch = match; 207 bestMatch = match;
208 } 208 }
209 } 209 }
210 return bestMatch; 210 return bestMatch;
211 } 211 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/RadioNodeList.cpp ('k') | third_party/WebKit/Source/core/html/URLRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698