| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 MIDIInput::MIDIInput(MIDIAccess* access, const String& id, const String& manufac
turer, const String& name, const String& version, PortState state) | 50 MIDIInput::MIDIInput(MIDIAccess* access, const String& id, const String& manufac
turer, const String& name, const String& version, PortState state) |
| 51 : MIDIPort(access, id, manufacturer, name, TypeInput, version, state) | 51 : MIDIPort(access, id, manufacturer, name, TypeInput, version, state) |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 EventListener* MIDIInput::onmidimessage() | 55 EventListener* MIDIInput::onmidimessage() |
| 56 { | 56 { |
| 57 return getAttributeEventListener(EventTypeNames::midimessage); | 57 return getAttributeEventListener(EventTypeNames::midimessage); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void MIDIInput::setOnmidimessage(PassRefPtr<EventListener> listener) | 60 void MIDIInput::setOnmidimessage(PassRefPtrWillBeRawPtr<EventListener> listener) |
| 61 { | 61 { |
| 62 // Implicit open. It does nothing if the port is already opened. | 62 // Implicit open. It does nothing if the port is already opened. |
| 63 // See http://www.w3.org/TR/webmidi/#widl-MIDIPort-open-Promise-MIDIPort | 63 // See http://www.w3.org/TR/webmidi/#widl-MIDIPort-open-Promise-MIDIPort |
| 64 open(); | 64 open(); |
| 65 | 65 |
| 66 setAttributeEventListener(EventTypeNames::midimessage, listener); | 66 setAttributeEventListener(EventTypeNames::midimessage, listener); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool MIDIInput::addEventListener(const AtomicString& eventType, PassRefPtr<Event
Listener> listener, bool useCapture) | 69 bool MIDIInput::addEventListener(const AtomicString& eventType, PassRefPtrWillBe
RawPtr<EventListener> listener, bool useCapture) |
| 70 { | 70 { |
| 71 if (eventType == EventTypeNames::midimessage) { | 71 if (eventType == EventTypeNames::midimessage) { |
| 72 // Implicit open. See setOnmidimessage(). | 72 // Implicit open. See setOnmidimessage(). |
| 73 open(); | 73 open(); |
| 74 } | 74 } |
| 75 return EventTarget::addEventListener(eventType, listener, useCapture); | 75 return EventTarget::addEventListener(eventType, listener, useCapture); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data
, size_t length, double timeStamp) | 78 void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data
, size_t length, double timeStamp) |
| 79 { | 79 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 RefPtr<DOMUint8Array> array = DOMUint8Array::create(data, length); | 93 RefPtr<DOMUint8Array> array = DOMUint8Array::create(data, length); |
| 94 dispatchEvent(MIDIMessageEvent::create(timeStamp, array)); | 94 dispatchEvent(MIDIMessageEvent::create(timeStamp, array)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 DEFINE_TRACE(MIDIInput) | 97 DEFINE_TRACE(MIDIInput) |
| 98 { | 98 { |
| 99 MIDIPort::trace(visitor); | 99 MIDIPort::trace(visitor); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |