OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 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 23 matching lines...) Expand all Loading... |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 typedef int ExceptionCode; | 36 typedef int ExceptionCode; |
37 | 37 |
38 class TimeRanges : public RefCounted<TimeRanges> { | 38 class TimeRanges : public RefCounted<TimeRanges> { |
39 public: | 39 public: |
40 static PassRefPtr<TimeRanges> create() | 40 static PassRefPtr<TimeRanges> create() |
41 { | 41 { |
42 return adoptRef(new TimeRanges); | 42 return adoptRef(new TimeRanges); |
43 } | 43 } |
44 static PassRefPtr<TimeRanges> create(float start, float end) | 44 static PassRefPtr<TimeRanges> create(double start, double end) |
45 { | 45 { |
46 return adoptRef(new TimeRanges(start, end)); | 46 return adoptRef(new TimeRanges(start, end)); |
47 } | 47 } |
48 | 48 |
49 PassRefPtr<TimeRanges> copy() const; | 49 PassRefPtr<TimeRanges> copy() const; |
50 void invert(); | 50 void invert(); |
51 void intersectWith(const TimeRanges*); | 51 void intersectWith(const TimeRanges*); |
52 void unionWith(const TimeRanges*); | 52 void unionWith(const TimeRanges*); |
53 | 53 |
54 unsigned length() const { return m_ranges.size(); } | 54 unsigned length() const { return m_ranges.size(); } |
55 float start(unsigned index, ExceptionCode&) const; | 55 double start(unsigned index, ExceptionCode&) const; |
56 float end(unsigned index, ExceptionCode&) const; | 56 double end(unsigned index, ExceptionCode&) const; |
57 | 57 |
58 void add(float start, float end); | 58 void add(double start, double end); |
59 | 59 |
60 bool contain(float time) const; | 60 bool contain(double time) const; |
61 | 61 |
62 float nearest(float time) const; | 62 double nearest(double time) const; |
63 | 63 |
64 private: | 64 private: |
65 TimeRanges() { } | 65 TimeRanges() { } |
66 TimeRanges(float start, float end); | 66 TimeRanges(double start, double end); |
67 TimeRanges(const TimeRanges&); | 67 TimeRanges(const TimeRanges&); |
68 | 68 |
69 // We consider all the Ranges to be semi-bounded as follow: [start, end[ | 69 // We consider all the Ranges to be semi-bounded as follow: [start, end[ |
70 struct Range { | 70 struct Range { |
71 Range() { } | 71 Range() { } |
72 Range(float start, float end) | 72 Range(double start, double end) |
73 { | 73 { |
74 m_start = start; | 74 m_start = start; |
75 m_end = end; | 75 m_end = end; |
76 } | 76 } |
77 float m_start; | 77 double m_start; |
78 float m_end; | 78 double m_end; |
79 | 79 |
80 inline bool isPointInRange(float point) const | 80 inline bool isPointInRange(double point) const |
81 { | 81 { |
82 return m_start <= point && point < m_end; | 82 return m_start <= point && point < m_end; |
83 } | 83 } |
84 | 84 |
85 inline bool isOverlappingRange(const Range& range) const | 85 inline bool isOverlappingRange(const Range& range) const |
86 { | 86 { |
87 return isPointInRange(range.m_start) || isPointInRange(range.m_end)
|| range.isPointInRange(m_start); | 87 return isPointInRange(range.m_start) || isPointInRange(range.m_end)
|| range.isPointInRange(m_start); |
88 } | 88 } |
89 | 89 |
90 inline bool isContiguousWithRange(const Range& range) const | 90 inline bool isContiguousWithRange(const Range& range) const |
(...skipping 16 matching lines...) Expand all Loading... |
107 return range.m_start >= m_end; | 107 return range.m_start >= m_end; |
108 } | 108 } |
109 }; | 109 }; |
110 | 110 |
111 Vector<Range> m_ranges; | 111 Vector<Range> m_ranges; |
112 }; | 112 }; |
113 | 113 |
114 } // namespace WebCore | 114 } // namespace WebCore |
115 | 115 |
116 #endif | 116 #endif |
OLD | NEW |