INPUT_SPEECH should be implemented as a PageSupplement.
authormorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 05:46:08 +0000 (05:46 +0000)
committermorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 05:46:08 +0000 (05:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79051

Source/WebCore:

Turned SpeechInput to a PageSupplement.

Reviewed by Adam Barth.

No new tests. No behavior change.

* html/shadow/TextControlInnerElements.cpp:
(WebCore::InputFieldSpeechButtonElement::speechInput):
(WebCore::InputFieldSpeechButtonElement::attach):
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::PageClients::PageClients):
* page/Page.h:
(WebCore):
(PageClients):
(Page):
* page/SpeechInput.cpp:
(WebCore::SpeechInput::supplementName):
(WebCore):
(WebCore::provideSpeechInputTo):
* page/SpeechInput.h:
(SpeechInput):
(WebCore::SpeechInput::from):
* page/SpeechInputClient.h:
(WebCore):

Source/WebKit/chromium:

Reviewed by Adam Barth.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::WebViewImpl):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108446 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/SpeechInput.cpp
Source/WebCore/page/SpeechInput.h
Source/WebCore/page/SpeechInputClient.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebViewImpl.cpp

index 00c6099..120213d 100644 (file)
@@ -1,3 +1,34 @@
+2012-02-21  MORITA Hajime <morrita@google.com>
+
+        INPUT_SPEECH should be implemented as a PageSupplement.
+        https://bugs.webkit.org/show_bug.cgi?id=79051
+
+        Turned SpeechInput to a PageSupplement.
+
+        Reviewed by Adam Barth.
+
+        No new tests. No behavior change.
+
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::InputFieldSpeechButtonElement::speechInput):
+        (WebCore::InputFieldSpeechButtonElement::attach):
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        (WebCore::Page::PageClients::PageClients):
+        * page/Page.h:
+        (WebCore):
+        (PageClients):
+        (Page):
+        * page/SpeechInput.cpp:
+        (WebCore::SpeechInput::supplementName):
+        (WebCore):
+        (WebCore::provideSpeechInputTo):
+        * page/SpeechInput.h:
+        (SpeechInput):
+        (WebCore::SpeechInput::from):
+        * page/SpeechInputClient.h:
+        (WebCore):
+
 2012-02-21  Alexandre Elias  <aelias@google.com>
 
         [chromium] Add three small zoom gesture features
index c44e4a6..2fc35f2 100644 (file)
@@ -474,7 +474,7 @@ void InputFieldSpeechButtonElement::setState(SpeechInputState state)
 
 SpeechInput* InputFieldSpeechButtonElement::speechInput()
 {
-    return document()->page() ? document()->page()->speechInput() : 0;
+    return SpeechInput::from(document()->page());
 }
 
 void InputFieldSpeechButtonElement::didCompleteRecording(int)
@@ -520,7 +520,8 @@ void InputFieldSpeechButtonElement::setRecognitionResult(int, const SpeechInputR
 void InputFieldSpeechButtonElement::attach()
 {
     ASSERT(!m_listenerId);
-    m_listenerId = document()->page()->speechInput()->registerListener(this);
+    if (SpeechInput* input = SpeechInput::from(document()->page()))
+        m_listenerId = input->registerListener(this);
     HTMLDivElement::attach();
 }
 
index ffd1b0e..5bda83d 100644 (file)
@@ -67,8 +67,6 @@
 #include "ScrollingCoordinator.h"
 #include "Settings.h"
 #include "SharedBuffer.h"
-#include "SpeechInput.h"
-#include "SpeechInputClient.h"
 #include "StorageArea.h"
 #include "StorageNamespace.h"
 #include "TextResourceDecoder.h"
@@ -137,9 +135,6 @@ Page::Page(PageClients& pageClients)
 #if ENABLE(POINTER_LOCK)
     , m_pointerLockController(PointerLockController::create(this))
 #endif
-#if ENABLE(INPUT_SPEECH)
-    , m_speechInputClient(pageClients.speechInputClient)
-#endif
     , m_settings(Settings::create(this))
     , m_progress(ProgressTracker::create())
     , m_backForwardController(BackForwardController::create(this, pageClients.backForwardClient))
@@ -950,16 +945,6 @@ double Page::minimumTimerInterval() const
     return m_minimumTimerInterval;
 }
 
-#if ENABLE(INPUT_SPEECH)
-SpeechInput* Page::speechInput()
-{
-    ASSERT(m_speechInputClient);
-    if (!m_speechInput.get())
-        m_speechInput = SpeechInput::create(m_speechInputClient);
-    return m_speechInput.get();
-}
-#endif
-
 void Page::dnsPrefetchingStateChanged()
 {
     for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
@@ -1084,7 +1069,6 @@ Page::PageClients::PageClients()
     , dragClient(0)
     , inspectorClient(0)
     , geolocationClient(0)
-    , speechInputClient(0)
     , notificationClient(0)
 {
 }
index 4b75806..d46f643 100644 (file)
@@ -83,8 +83,6 @@ namespace WebCore {
     class ScrollableArea;
     class ScrollingCoordinator;
     class Settings;
-    class SpeechInput;
-    class SpeechInputClient;
     class StorageNamespace;
 #if ENABLE(NOTIFICATIONS)
     class NotificationPresenter;
@@ -116,7 +114,6 @@ namespace WebCore {
             InspectorClient* inspectorClient;
             GeolocationClient* geolocationClient;
             RefPtr<BackForwardList> backForwardClient;
-            SpeechInputClient* speechInputClient;
             NotificationPresenter* notificationClient;
         };
 
@@ -184,9 +181,7 @@ namespace WebCore {
 #if ENABLE(POINTER_LOCK)
         PointerLockController* pointerLockController() const { return m_pointerLockController.get(); }
 #endif
-#if ENABLE(INPUT_SPEECH)
-        SpeechInput* speechInput();
-#endif
+
         ScrollingCoordinator* scrollingCoordinator();
 
         Settings* settings() const { return m_settings.get(); }
@@ -380,10 +375,6 @@ namespace WebCore {
 #if ENABLE(POINTER_LOCK)
         OwnPtr<PointerLockController> m_pointerLockController;
 #endif
-#if ENABLE(INPUT_SPEECH)
-        SpeechInputClient* m_speechInputClient;
-        OwnPtr<SpeechInput> m_speechInput;
-#endif
         RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
 
         OwnPtr<Settings> m_settings;
index 6a8620a..4d7290c 100644 (file)
@@ -117,6 +117,17 @@ void SpeechInput::cancelRecognition(int listenerId)
     m_client->cancelRecognition(listenerId);
 }
 
+const AtomicString& SpeechInput::supplementName()
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("SpeechInput"));
+    return name;
+}
+
+void provideSpeechInputTo(Page* page, SpeechInputClient* client)
+{
+    PageSupplement::provideTo(page, SpeechInput::supplementName(), SpeechInput::create(client));
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INPUT_SPEECH)
index 6fee65c..bab9e36 100644 (file)
@@ -33,6 +33,7 @@
 
 #if ENABLE(INPUT_SPEECH)
 
+#include "PageSupplement.h"
 #include "SpeechInputListener.h"
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
@@ -47,12 +48,16 @@ class SpeechInputListener;
 // This class connects the input elements requiring speech input with the platform specific
 // speech recognition engine. It provides methods for the input elements to activate speech
 // recognition and methods for the speech recognition engine to return back the results.
-class SpeechInput : public SpeechInputListener {
+class SpeechInput : public SpeechInputListener,
+                    public PageSupplement {
     WTF_MAKE_NONCOPYABLE(SpeechInput);
 public:
     virtual ~SpeechInput();
 
     static PassOwnPtr<SpeechInput> create(SpeechInputClient*);
+    static const AtomicString& supplementName();
+    static SpeechInput* from(Frame* frame) { return static_cast<SpeechInput*>(PageSupplement::from(frame, supplementName())); }
+    static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(PageSupplement::from(page, supplementName())); }
 
     // Generates a unique ID for the given listener to be used for speech requests.
     // This should be the first call made by listeners before anything else.
index 4f8fd5e..e26f979 100644 (file)
@@ -40,6 +40,7 @@ namespace WebCore {
 class IntRect;
 class SecurityOrigin;
 class SpeechInputListener;
+class Page;
 
 // Provides an interface for SpeechInput to call into the embedder.
 class SpeechInputClient {
@@ -65,6 +66,8 @@ protected:
     virtual ~SpeechInputClient() { }
 };
 
+void provideSpeechInputTo(Page*, SpeechInputClient*);
+
 } // namespace WebCore
 
 #endif // ENABLE(INPUT_SPEECH)
index 295cdba..0f8275a 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-21  MORITA Hajime  <morrita@google.com>
+
+        INPUT_SPEECH should be implemented as a PageSupplement.
+        https://bugs.webkit.org/show_bug.cgi?id=79051
+
+        Reviewed by Adam Barth.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::WebViewImpl):
+
 2012-02-20  MORITA Hajime  <morrita@google.com>
 
         MEDIA_STREAM should be implemented as a PageSupplement.
index cfdc195..e3af8eb 100644 (file)
@@ -397,9 +397,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
     pageClients.editorClient = &m_editorClientImpl;
     pageClients.dragClient = &m_dragClientImpl;
     pageClients.inspectorClient = &m_inspectorClientImpl;
-#if ENABLE(INPUT_SPEECH)
-    pageClients.speechInputClient = m_speechInputClient.get();
-#endif
     pageClients.geolocationClient = m_geolocationClientProxy.get();
 #if ENABLE(NOTIFICATIONS)
     pageClients.notificationClient = notificationPresenterImpl();
@@ -410,6 +407,10 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
 #if ENABLE(MEDIA_STREAM)
     provideUserMediaTo(m_page.get(), &m_userMediaClientImpl);
 #endif
+#if ENABLE(INPUT_SPEECH)
+    provideSpeechInputTo(m_page.get(), m_speechInputClient.get());
+#endif
+
     provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
     m_geolocationClientProxy->setController(m_page->geolocationController());