| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * * Redistributions of source code must retain the above copyright | 7 * * 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 * * Redistributions in binary form must reproduce the above copyright | 9 * * 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 19 matching lines...) Expand all Loading... |
| 30 #include "bindings/v8/ExceptionState.h" | 30 #include "bindings/v8/ExceptionState.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
| 34 #include "modules/speech/SpeechRecognitionController.h" | 34 #include "modules/speech/SpeechRecognitionController.h" |
| 35 #include "modules/speech/SpeechRecognitionError.h" | 35 #include "modules/speech/SpeechRecognitionError.h" |
| 36 #include "modules/speech/SpeechRecognitionEvent.h" | 36 #include "modules/speech/SpeechRecognitionEvent.h" |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 PassRefPtrWillBeRawPtr<SpeechRecognition> SpeechRecognition::create(ExecutionCon
text* context) | 40 SpeechRecognition* SpeechRecognition::create(ExecutionContext* context) |
| 41 { | 41 { |
| 42 RefPtrWillBeRawPtr<SpeechRecognition> speechRecognition = adoptRefWillBeNoop
(new SpeechRecognition(context)); | 42 SpeechRecognition* speechRecognition = adoptRefCountedGarbageCollectedWillBe
Noop(new SpeechRecognition(context)); |
| 43 speechRecognition->suspendIfNeeded(); | 43 speechRecognition->suspendIfNeeded(); |
| 44 return speechRecognition.release(); | 44 return speechRecognition; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SpeechRecognition::start(ExceptionState& exceptionState) | 47 void SpeechRecognition::start(ExceptionState& exceptionState) |
| 48 { | 48 { |
| 49 ASSERT(m_controller); | 49 ASSERT(m_controller); |
| 50 if (m_started) { | 50 if (m_started) { |
| 51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr
eady started."); | 51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr
eady started."); |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void SpeechRecognition::didEndSound() | 98 void SpeechRecognition::didEndSound() |
| 99 { | 99 { |
| 100 dispatchEvent(Event::create(EventTypeNames::soundend)); | 100 dispatchEvent(Event::create(EventTypeNames::soundend)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void SpeechRecognition::didEndAudio() | 103 void SpeechRecognition::didEndAudio() |
| 104 { | 104 { |
| 105 dispatchEvent(Event::create(EventTypeNames::audioend)); | 105 dispatchEvent(Event::create(EventTypeNames::audioend)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void SpeechRecognition::didReceiveResults(const WillBeHeapVector<RefPtrWillBeMem
ber<SpeechRecognitionResult> >& newFinalResults, const WillBeHeapVector<RefPtrWi
llBeMember<SpeechRecognitionResult> >& currentInterimResults) | 108 void SpeechRecognition::didReceiveResults(const HeapVector<Member<SpeechRecognit
ionResult> >& newFinalResults, const HeapVector<Member<SpeechRecognitionResult>
>& currentInterimResults) |
| 109 { | 109 { |
| 110 unsigned long resultIndex = m_finalResults.size(); | 110 unsigned long resultIndex = m_finalResults.size(); |
| 111 | 111 |
| 112 for (size_t i = 0; i < newFinalResults.size(); ++i) | 112 for (size_t i = 0; i < newFinalResults.size(); ++i) |
| 113 m_finalResults.append(newFinalResults[i]); | 113 m_finalResults.append(newFinalResults[i]); |
| 114 | 114 |
| 115 WillBeHeapVector<RefPtrWillBeMember<SpeechRecognitionResult> > results = m_f
inalResults; | 115 HeapVector<Member<SpeechRecognitionResult> > results = m_finalResults; |
| 116 for (size_t i = 0; i < currentInterimResults.size(); ++i) | 116 for (size_t i = 0; i < currentInterimResults.size(); ++i) |
| 117 results.append(currentInterimResults[i]); | 117 results.append(currentInterimResults[i]); |
| 118 | 118 |
| 119 dispatchEvent(SpeechRecognitionEvent::createResult(resultIndex, results)); | 119 dispatchEvent(SpeechRecognitionEvent::createResult(resultIndex, results)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void SpeechRecognition::didReceiveNoMatch(PassRefPtrWillBeRawPtr<SpeechRecogniti
onResult> result) | 122 void SpeechRecognition::didReceiveNoMatch(SpeechRecognitionResult* result) |
| 123 { | 123 { |
| 124 dispatchEvent(SpeechRecognitionEvent::createNoMatch(result)); | 124 dispatchEvent(SpeechRecognitionEvent::createNoMatch(result)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void SpeechRecognition::didReceiveError(PassRefPtrWillBeRawPtr<SpeechRecognition
Error> error) | 127 void SpeechRecognition::didReceiveError(PassRefPtrWillBeRawPtr<SpeechRecognition
Error> error) |
| 128 { | 128 { |
| 129 dispatchEvent(error); | 129 dispatchEvent(error); |
| 130 m_started = false; | 130 m_started = false; |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SpeechRecognition::trace(Visitor* visitor) | 195 void SpeechRecognition::trace(Visitor* visitor) |
| 196 { | 196 { |
| 197 visitor->trace(m_grammars); | 197 visitor->trace(m_grammars); |
| 198 visitor->trace(m_finalResults); | 198 visitor->trace(m_finalResults); |
| 199 EventTargetWithInlineData::trace(visitor); | 199 EventTargetWithInlineData::trace(visitor); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace WebCore | 202 } // namespace WebCore |
| OLD | NEW |