Title: [270846] trunk
Revision
270846
Author
[email protected]
Date
2020-12-15 09:38:14 -0800 (Tue, 15 Dec 2020)

Log Message

resultIndex of SpeechRecognitionEvent should be the first index that has change
https://bugs.webkit.org/show_bug.cgi?id=219876

Reviewed by Youenn Fablet.

Source/WebCore:

Our current resultIndex is first index of non-final result, but it should be first index of changed result
(https://wicg.github.io/speech-api/#dom-speechrecognitionevent-resultindex), which includes result with state
change (non-final to final) but no content change.

Modified existing test: fast/speechrecognition/ios/start-recognition-then-stop.html

* Modules/speech/SpeechRecognition.cpp:
(WebCore::SpeechRecognition::didReceiveResult):

LayoutTests:

* fast/speechrecognition/ios/start-recognition-then-stop-expected.txt:
* fast/speechrecognition/ios/start-recognition-then-stop.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270845 => 270846)


--- trunk/LayoutTests/ChangeLog	2020-12-15 17:30:33 UTC (rev 270845)
+++ trunk/LayoutTests/ChangeLog	2020-12-15 17:38:14 UTC (rev 270846)
@@ -1,3 +1,13 @@
+2020-12-15  Sihui Liu  <[email protected]>
+
+        resultIndex of SpeechRecognitionEvent should be the first index that has change
+        https://bugs.webkit.org/show_bug.cgi?id=219876
+
+        Reviewed by Youenn Fablet.
+
+        * fast/speechrecognition/ios/start-recognition-then-stop-expected.txt:
+        * fast/speechrecognition/ios/start-recognition-then-stop.html:
+
 2020-12-15  Zalan Bujtas  <[email protected]>
 
         REGRESSION: apple.com sign-in page footer does not wrap, "Site Map" option renders offscreen.

Modified: trunk/LayoutTests/fast/speechrecognition/ios/start-recognition-then-stop-expected.txt (270845 => 270846)


--- trunk/LayoutTests/fast/speechrecognition/ios/start-recognition-then-stop-expected.txt	2020-12-15 17:30:33 UTC (rev 270845)
+++ trunk/LayoutTests/fast/speechrecognition/ios/start-recognition-then-stop-expected.txt	2020-12-15 17:38:14 UTC (rev 270846)
@@ -9,6 +9,7 @@
 Received audiostart event
 Received speechstart event
 Received result event
+PASS event.resultIndex is 0
 PASS event.results.length is 1
 PASS event.results.item(0).isFinal is true
 PASS event.results.item(0).length is 1

Modified: trunk/LayoutTests/fast/speechrecognition/ios/start-recognition-then-stop.html (270845 => 270846)


--- trunk/LayoutTests/fast/speechrecognition/ios/start-recognition-then-stop.html	2020-12-15 17:30:33 UTC (rev 270845)
+++ trunk/LayoutTests/fast/speechrecognition/ios/start-recognition-then-stop.html	2020-12-15 17:38:14 UTC (rev 270846)
@@ -31,6 +31,7 @@
     hasReceivedResult = true;
 
     debug("Received result event");
+    shouldBe("event.resultIndex", "0");
     shouldBe("event.results.length", "1");
     shouldBeTrue("event.results.item(0).isFinal");
     shouldBe("event.results.item(0).length", "1");

Modified: trunk/Source/WebCore/ChangeLog (270845 => 270846)


--- trunk/Source/WebCore/ChangeLog	2020-12-15 17:30:33 UTC (rev 270845)
+++ trunk/Source/WebCore/ChangeLog	2020-12-15 17:38:14 UTC (rev 270846)
@@ -1,3 +1,19 @@
+2020-12-15  Sihui Liu  <[email protected]>
+
+        resultIndex of SpeechRecognitionEvent should be the first index that has change
+        https://bugs.webkit.org/show_bug.cgi?id=219876
+
+        Reviewed by Youenn Fablet.
+
+        Our current resultIndex is first index of non-final result, but it should be first index of changed result
+        (https://wicg.github.io/speech-api/#dom-speechrecognitionevent-resultindex), which includes result with state
+        change (non-final to final) but no content change.
+
+        Modified existing test: fast/speechrecognition/ios/start-recognition-then-stop.html
+
+        * Modules/speech/SpeechRecognition.cpp:
+        (WebCore::SpeechRecognition::didReceiveResult):
+
 2020-12-15  Noam Rosenthal  <[email protected]>
 
         REGRESSION(r268886): Page load time performance regression

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognition.cpp (270845 => 270846)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognition.cpp	2020-12-15 17:30:33 UTC (rev 270845)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognition.cpp	2020-12-15 17:38:14 UTC (rev 270846)
@@ -148,7 +148,7 @@
     allResults.reserveCapacity(m_finalResults.size() + resultDatas.size());
     allResults.appendVector(m_finalResults);
 
-    auto nonFinalResultIndex = allResults.size();
+    auto firstChangedIndex = allResults.size();
     for (auto resultData : resultDatas) {
         auto alternatives = WTF::map(resultData.alternatives, [](auto& alternativeData) {
             return SpeechRecognitionAlternative::create(WTFMove(alternativeData.transcript), alternativeData.confidence);
@@ -155,15 +155,14 @@
         });
 
         auto newResult = SpeechRecognitionResult::create(WTFMove(alternatives), resultData.isFinal);
-        if (resultData.isFinal) {
+        if (resultData.isFinal)
             m_finalResults.append(newResult);
-            ++nonFinalResultIndex;
-        }
+
         allResults.append(WTFMove(newResult));
     }
 
     auto resultList = SpeechRecognitionResultList::create(WTFMove(allResults));
-    queueTaskToDispatchEvent(*this, TaskSource::Speech, SpeechRecognitionEvent::create(eventNames().resultEvent, nonFinalResultIndex, WTFMove(resultList)));
+    queueTaskToDispatchEvent(*this, TaskSource::Speech, SpeechRecognitionEvent::create(eventNames().resultEvent, firstChangedIndex, WTFMove(resultList)));
 }
 
 void SpeechRecognition::didError(const SpeechRecognitionError& error)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to