Modified: trunk/Source/WebCore/ChangeLog (123631 => 123632)
--- trunk/Source/WebCore/ChangeLog 2012-07-25 17:39:24 UTC (rev 123631)
+++ trunk/Source/WebCore/ChangeLog 2012-07-25 17:41:03 UTC (rev 123632)
@@ -1,3 +1,19 @@
+2012-07-25 Hans Wennborg <h...@chromium.org>
+
+ Speech _javascript_ API: extract function from SpeechRecognitionResult::emma()
+ https://bugs.webkit.org/show_bug.cgi?id=92232
+
+ Reviewed by Adam Barth.
+
+ Extract code for creating emma-qualified names to a helper function.
+
+ Just a refactoring; covered by the existing test.
+
+ * Modules/speech/SpeechRecognitionResult.cpp:
+ (WebCore::emmaQualifiedName):
+ (WebCore):
+ (WebCore::SpeechRecognitionResult::emma):
+
2012-07-25 Adrienne Walker <e...@google.com>
[chromium] Unify compositor quadTransform/drawTransform/originTransform
Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp (123631 => 123632)
--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp 2012-07-25 17:39:24 UTC (rev 123631)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp 2012-07-25 17:41:03 UTC (rev 123632)
@@ -52,6 +52,12 @@
return m_alternatives[index].get();
}
+static QualifiedName emmaQualifiedName(const char* localName)
+{
+ const char emmaNamespaceUrl[] = "http://www.w3.org/2003/04/emma";
+ return QualifiedName("emma", localName, emmaNamespaceUrl);
+}
+
Document* SpeechRecognitionResult::emma()
{
if (m_emma)
@@ -59,27 +65,26 @@
RefPtr<Document> document = Document::create(0, KURL());
- const char emmaNamespaceUrl[] = "http://www.w3.org/2003/04/emma";
- RefPtr<Element> emmaElement = document->createElement(QualifiedName("emma", "emma", emmaNamespaceUrl), false);
+ RefPtr<Element> emmaElement = document->createElement(emmaQualifiedName("emma"), false);
ExceptionCode ec = 0;
emmaElement->setAttribute("version", "1.0", ec);
ASSERT(!ec);
if (ec)
return 0;
- RefPtr<Element> _oneOf_ = document->createElement(QualifiedName("emma", "one-of", emmaNamespaceUrl), false);
- oneOf->setAttribute(QualifiedName("emma", "medium", emmaNamespaceUrl), "acoustic");
- oneOf->setAttribute(QualifiedName("emma", "mode", emmaNamespaceUrl), "voice");
+ RefPtr<Element> _oneOf_ = document->createElement(emmaQualifiedName("one-of"), false);
+ oneOf->setAttribute(emmaQualifiedName("medium"), "acoustic");
+ oneOf->setAttribute(emmaQualifiedName("mode"), "voice");
oneOf->setIdAttribute("one-of");
for (size_t i = 0; i < m_alternatives.size(); ++i) {
const RefPtr<SpeechRecognitionAlternative>& alternative = m_alternatives[i];
- RefPtr<Element> interpretation = document->createElement(QualifiedName("emma", "interpretation", emmaNamespaceUrl), false);
+ RefPtr<Element> interpretation = document->createElement(emmaQualifiedName("interpretation"), false);
interpretation->setIdAttribute(String::number(i + 1));
- interpretation->setAttribute(QualifiedName("emma", "confidence", emmaNamespaceUrl), String::number(alternative->confidence()));
+ interpretation->setAttribute(emmaQualifiedName("confidence"), String::number(alternative->confidence()));
- RefPtr<Element> literal = document->createElement(QualifiedName("emma", "literal", emmaNamespaceUrl), false);
+ RefPtr<Element> literal = document->createElement(emmaQualifiedName("literal"), false);
literal->appendChild(document->createTextNode(alternative->transcript()));
interpretation->appendChild(literal.release());
oneOf->appendChild(interpretation.release());