~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/html/TimeRanges.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2007 Apple Inc. All rights reserved.
 
2
 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
27
27
#define TimeRanges_h
28
28
 
29
29
#include "ExceptionCode.h"
 
30
 
 
31
#include <algorithm>
30
32
#include <wtf/PassRefPtr.h>
31
33
#include <wtf/RefCounted.h>
32
34
#include <wtf/Vector.h>
44
46
        return adoptRef(new TimeRanges(start, end));
45
47
    }
46
48
 
 
49
    PassRefPtr<TimeRanges> copy();
 
50
 
47
51
    unsigned length() const { return m_ranges.size(); }
48
52
    float start(unsigned index, ExceptionCode&) const;
49
53
    float end(unsigned index, ExceptionCode&) const;
55
59
private:
56
60
    TimeRanges() { }
57
61
    TimeRanges(float start, float end);
58
 
    
 
62
    TimeRanges(const TimeRanges&);
 
63
 
 
64
    // We consider all the Ranges to be semi-bounded as follow: [start, end[
59
65
    struct Range {
60
66
        Range() { }
61
 
        Range(float start, float end) {
 
67
        Range(float start, float end)
 
68
        {
62
69
            m_start = start;
63
70
            m_end = end;
64
71
        }
65
72
        float m_start;
66
73
        float m_end;
 
74
 
 
75
        inline bool isPointInRange(float point) const
 
76
        {
 
77
            return m_start <= point && point < m_end;
 
78
        }
 
79
        
 
80
        inline bool isOverlappingRange(const Range& range) const
 
81
        {
 
82
            return isPointInRange(range.m_start) || isPointInRange(range.m_end) || range.isPointInRange(m_start);
 
83
        }
 
84
 
 
85
        inline bool isContiguousWithRange(const Range& range) const
 
86
        {
 
87
            return range.m_start == m_end || range.m_end == m_start;
 
88
        }
 
89
        
 
90
        inline Range unionWithOverlappingOrContiguousRange(const Range& range) const
 
91
        {
 
92
            Range ret;
 
93
 
 
94
            ret.m_start = std::min(m_start, range.m_start);
 
95
            ret.m_end = std::max(m_end, range.m_end);
 
96
 
 
97
            return ret;
 
98
        }
 
99
 
 
100
        inline bool isBeforeRange(const Range& range) const
 
101
        {
 
102
            return range.m_start >= m_end;
 
103
        }
67
104
    };
68
105
    
69
106
    Vector<Range> m_ranges;