OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
3 * Copyright (c) 2010, Google Inc. All rights reserved. | 3 * Copyright (c) 2010, Google 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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 // Overridden from ArrayBufferView. This must be public because of | 47 // Overridden from ArrayBufferView. This must be public because of |
48 // rules about inheritance of members in template classes, and | 48 // rules about inheritance of members in template classes, and |
49 // because it is accessed via pointers to subclasses. | 49 // because it is accessed via pointers to subclasses. |
50 unsigned length() const | 50 unsigned length() const |
51 { | 51 { |
52 return m_length; | 52 return m_length; |
53 } | 53 } |
54 | 54 |
55 virtual unsigned byteLength() const override final | 55 unsigned byteLength() const final |
56 { | 56 { |
57 return m_length * sizeof(T); | 57 return m_length * sizeof(T); |
58 } | 58 } |
59 | 59 |
60 // Invoked by the indexed getter. Does not perform range checks; caller | 60 // Invoked by the indexed getter. Does not perform range checks; caller |
61 // is responsible for doing so and returning undefined as necessary. | 61 // is responsible for doing so and returning undefined as necessary. |
62 T item(unsigned index) const | 62 T item(unsigned index) const |
63 { | 63 { |
64 ASSERT_WITH_SECURITY_IMPLICATION(index < TypedArrayBase<T>::m_length); | 64 ASSERT_WITH_SECURITY_IMPLICATION(index < TypedArrayBase<T>::m_length); |
65 return TypedArrayBase<T>::data()[index]; | 65 return TypedArrayBase<T>::data()[index]; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 template <class Subclass> | 102 template <class Subclass> |
103 static PassRefPtr<Subclass> createOrNull(unsigned length) | 103 static PassRefPtr<Subclass> createOrNull(unsigned length) |
104 { | 104 { |
105 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createOrNull(length, sizeof(T)
); | 105 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createOrNull(length, sizeof(T)
); |
106 if (!buffer) | 106 if (!buffer) |
107 return nullptr; | 107 return nullptr; |
108 return create<Subclass>(buffer.release(), 0, length); | 108 return create<Subclass>(buffer.release(), 0, length); |
109 } | 109 } |
110 | 110 |
111 virtual void neuter() override final | 111 void neuter() final |
112 { | 112 { |
113 ArrayBufferView::neuter(); | 113 ArrayBufferView::neuter(); |
114 m_length = 0; | 114 m_length = 0; |
115 } | 115 } |
116 | 116 |
117 // We do not want to have to access this via a virtual function in subclasse
s, | 117 // We do not want to have to access this via a virtual function in subclasse
s, |
118 // which is why it is protected rather than private. | 118 // which is why it is protected rather than private. |
119 unsigned m_length; | 119 unsigned m_length; |
120 }; | 120 }; |
121 | 121 |
122 } // namespace WTF | 122 } // namespace WTF |
123 | 123 |
124 using WTF::TypedArrayBase; | 124 using WTF::TypedArrayBase; |
125 | 125 |
126 #endif // TypedArrayBase_h | 126 #endif // TypedArrayBase_h |
OLD | NEW |