| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "bindings/v8/ExceptionMessages.h" | 35 #include "bindings/v8/ExceptionMessages.h" |
| 36 #include "bindings/v8/ExceptionStatePlaceholder.h" | 36 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 38 #include "core/html/track/TextTrack.h" | 38 #include "core/html/track/TextTrack.h" |
| 39 #include "core/html/track/TextTrackCueList.h" | 39 #include "core/html/track/TextTrackCueList.h" |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 static const int invalidCueIndex = -1; | 43 static const int invalidCueIndex = -1; |
| 44 | 44 |
| 45 bool TextTrackCue::isInfiniteOrNonNumber(double value, ExceptionState& exception
State) | |
| 46 { | |
| 47 if (!std::isfinite(value)) { | |
| 48 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(value)
); | |
| 49 return true; | |
| 50 } | |
| 51 return false; | |
| 52 } | |
| 53 | |
| 54 TextTrackCue::TextTrackCue(double start, double end) | 45 TextTrackCue::TextTrackCue(double start, double end) |
| 55 : m_startTime(start) | 46 : m_startTime(start) |
| 56 , m_endTime(end) | 47 , m_endTime(end) |
| 57 , m_cueIndex(invalidCueIndex) | 48 , m_cueIndex(invalidCueIndex) |
| 58 , m_track(nullptr) | 49 , m_track(nullptr) |
| 59 , m_isActive(false) | 50 , m_isActive(false) |
| 60 , m_pauseOnExit(false) | 51 , m_pauseOnExit(false) |
| 61 { | 52 { |
| 62 } | 53 } |
| 63 | 54 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 void TextTrackCue::setId(const AtomicString& id) | 82 void TextTrackCue::setId(const AtomicString& id) |
| 92 { | 83 { |
| 93 if (m_id == id) | 84 if (m_id == id) |
| 94 return; | 85 return; |
| 95 | 86 |
| 96 cueWillChange(); | 87 cueWillChange(); |
| 97 m_id = id; | 88 m_id = id; |
| 98 cueDidChange(); | 89 cueDidChange(); |
| 99 } | 90 } |
| 100 | 91 |
| 101 void TextTrackCue::setStartTime(double value, ExceptionState& exceptionState) | 92 void TextTrackCue::setStartTime(double value) |
| 102 { | 93 { |
| 103 // NaN, Infinity and -Infinity values should trigger a TypeError. | |
| 104 if (isInfiniteOrNonNumber(value, exceptionState)) | |
| 105 return; | |
| 106 | |
| 107 // TODO(93143): Add spec-compliant behavior for negative time values. | 94 // TODO(93143): Add spec-compliant behavior for negative time values. |
| 108 if (m_startTime == value || value < 0) | 95 if (m_startTime == value || value < 0) |
| 109 return; | 96 return; |
| 110 | 97 |
| 111 cueWillChange(); | 98 cueWillChange(); |
| 112 m_startTime = value; | 99 m_startTime = value; |
| 113 cueDidChange(); | 100 cueDidChange(); |
| 114 } | 101 } |
| 115 | 102 |
| 116 void TextTrackCue::setEndTime(double value, ExceptionState& exceptionState) | 103 void TextTrackCue::setEndTime(double value) |
| 117 { | 104 { |
| 118 // NaN, Infinity and -Infinity values should trigger a TypeError. | |
| 119 if (isInfiniteOrNonNumber(value, exceptionState)) | |
| 120 return; | |
| 121 | |
| 122 // TODO(93143): Add spec-compliant behavior for negative time values. | 105 // TODO(93143): Add spec-compliant behavior for negative time values. |
| 123 if (m_endTime == value || value < 0) | 106 if (m_endTime == value || value < 0) |
| 124 return; | 107 return; |
| 125 | 108 |
| 126 cueWillChange(); | 109 cueWillChange(); |
| 127 m_endTime = value; | 110 m_endTime = value; |
| 128 cueDidChange(); | 111 cueDidChange(); |
| 129 } | 112 } |
| 130 | 113 |
| 131 void TextTrackCue::setPauseOnExit(bool value) | 114 void TextTrackCue::setPauseOnExit(bool value) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 { | 161 { |
| 179 return EventTargetNames::TextTrackCue; | 162 return EventTargetNames::TextTrackCue; |
| 180 } | 163 } |
| 181 | 164 |
| 182 void TextTrackCue::trace(Visitor* visitor) | 165 void TextTrackCue::trace(Visitor* visitor) |
| 183 { | 166 { |
| 184 visitor->trace(m_track); | 167 visitor->trace(m_track); |
| 185 } | 168 } |
| 186 | 169 |
| 187 } // namespace WebCore | 170 } // namespace WebCore |
| OLD | NEW |