From 51901d29fd4105648fc0d5b2ab04c3ef2590d769 Mon Sep 17 00:00:00 2001 From: "morrita@google.com" Date: Wed, 22 Feb 2012 05:46:08 +0000 Subject: [PATCH] INPUT_SPEECH should be implemented as a PageSupplement. 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: http://svn.webkit.org/repository/webkit/trunk@108446 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 31 ++++++++++++++++++++++ .../html/shadow/TextControlInnerElements.cpp | 5 ++-- Source/WebCore/page/Page.cpp | 16 ----------- Source/WebCore/page/Page.h | 11 +------- Source/WebCore/page/SpeechInput.cpp | 11 ++++++++ Source/WebCore/page/SpeechInput.h | 7 ++++- Source/WebCore/page/SpeechInputClient.h | 3 +++ Source/WebKit/chromium/ChangeLog | 10 +++++++ Source/WebKit/chromium/src/WebViewImpl.cpp | 7 ++--- 9 files changed, 69 insertions(+), 32 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 00c6099..120213d 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,34 @@ +2012-02-21 MORITA Hajime + + 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 [chromium] Add three small zoom gesture features diff --git a/Source/WebCore/html/shadow/TextControlInnerElements.cpp b/Source/WebCore/html/shadow/TextControlInnerElements.cpp index c44e4a6..2fc35f2 100644 --- a/Source/WebCore/html/shadow/TextControlInnerElements.cpp +++ b/Source/WebCore/html/shadow/TextControlInnerElements.cpp @@ -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(); } diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp index ffd1b0e..5bda83d 100644 --- a/Source/WebCore/page/Page.cpp +++ b/Source/WebCore/page/Page.cpp @@ -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) { } diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h index 4b75806..d46f643 100644 --- a/Source/WebCore/page/Page.h +++ b/Source/WebCore/page/Page.h @@ -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 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 m_pointerLockController; #endif -#if ENABLE(INPUT_SPEECH) - SpeechInputClient* m_speechInputClient; - OwnPtr m_speechInput; -#endif RefPtr m_scrollingCoordinator; OwnPtr m_settings; diff --git a/Source/WebCore/page/SpeechInput.cpp b/Source/WebCore/page/SpeechInput.cpp index 6a8620a..4d7290c 100644 --- a/Source/WebCore/page/SpeechInput.cpp +++ b/Source/WebCore/page/SpeechInput.cpp @@ -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) diff --git a/Source/WebCore/page/SpeechInput.h b/Source/WebCore/page/SpeechInput.h index 6fee65c..bab9e36 100644 --- a/Source/WebCore/page/SpeechInput.h +++ b/Source/WebCore/page/SpeechInput.h @@ -33,6 +33,7 @@ #if ENABLE(INPUT_SPEECH) +#include "PageSupplement.h" #include "SpeechInputListener.h" #include #include @@ -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 create(SpeechInputClient*); + static const AtomicString& supplementName(); + static SpeechInput* from(Frame* frame) { return static_cast(PageSupplement::from(frame, supplementName())); } + static SpeechInput* from(Page* page) { return static_cast(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. diff --git a/Source/WebCore/page/SpeechInputClient.h b/Source/WebCore/page/SpeechInputClient.h index 4f8fd5e..e26f979 100644 --- a/Source/WebCore/page/SpeechInputClient.h +++ b/Source/WebCore/page/SpeechInputClient.h @@ -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) diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 295cdba..0f8275a 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,13 @@ +2012-02-21 MORITA Hajime + + 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 MEDIA_STREAM should be implemented as a PageSupplement. diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index cfdc195..e3af8eb 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -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()); -- 2.7.4