[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jorlow at chromium.org jorlow at chromium.org
Wed Dec 22 11:52:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4654da765deaf5c50dd770f3ec3868aca58c2f2d
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 10 10:13:51 2010 +0000

    2010-08-10  Hans Wennborg  <hans at chromium.org>
    
            Reviewed by Jeremy Orlow.
    
            Implement chromium WebDeviceOrientationClient wrapper and have WebViewImpl get it from WebViewClient.
            https://bugs.webkit.org/show_bug.cgi?id=43258
    
            Provide a DeviceOrientationClient to Page by means of a
            DeviceOrientationClientProxy that proxies calls to
            a WebDeviceOrientationClient, an interface that can be implemented
            in the WebKit or Chromium layer. An implementation to be used for
            layout tests, wrapping DeviceOrientationClientMock, is provided.
    
            * WebKit.gyp:
            * public/WebDeviceOrientation.h: Added.
            (WebKit::WebDeviceOrientation::WebDeviceOrientation):
            * public/WebDeviceOrientationClient.h: Added.
            (WebKit::WebDeviceOrientationClient::~WebDeviceOrientationClient):
            * public/WebDeviceOrientationClientMock.h: Added.
            (WebKit::WebDeviceOrientationClientMock::WebDeviceOrientationClientMock):
            (WebKit::WebDeviceOrientationClientMock::~WebDeviceOrientationClientMock):
            * public/WebDeviceOrientationController.h: Added.
            (WebKit::WebDeviceOrientationController::WebDeviceOrientationController):
            * public/WebViewClient.h:
            (WebKit::WebViewClient::deviceOrientationClient):
            * src/DeviceOrientationClientProxy.cpp: Added.
            (WebKit::DeviceOrientationClientProxy::setController):
            (WebKit::DeviceOrientationClientProxy::startUpdating):
            (WebKit::DeviceOrientationClientProxy::stopUpdating):
            (WebKit::DeviceOrientationClientProxy::lastOrientation):
            * src/DeviceOrientationClientProxy.h: Added.
            (WebKit::DeviceOrientationClientProxy::DeviceOrientationClientProxy):
            * src/WebDeviceOrientation.cpp: Added.
            (WebKit::WebDeviceOrientation::WebDeviceOrientation):
            (WebKit::WebDeviceOrientation::operator=):
            (WebKit::WebDeviceOrientation::operator PassRefPtr<WebCore::DeviceOrientation>):
            * src/WebDeviceOrientationClientMock.cpp: Added.
            (WebKit::WebDeviceOrientationClientMock::setController):
            (WebKit::WebDeviceOrientationClientMock::startUpdating):
            (WebKit::WebDeviceOrientationClientMock::stopUpdating):
            (WebKit::WebDeviceOrientationClientMock::lastOrientation):
            (WebKit::WebDeviceOrientationClientMock::setOrientation):
            (WebKit::WebDeviceOrientationClientMock::initialize):
            (WebKit::WebDeviceOrientationClientMock::reset):
            * src/WebDeviceOrientationController.cpp: Added.
            (WebKit::WebDeviceOrientationController::didChangeDeviceOrientation):
            (WebKit::WebDeviceOrientationController::controller):
            * src/WebViewImpl.cpp:
            (WebKit::WebView::create):
            (WebKit::WebViewImpl::WebViewImpl):
            * src/WebViewImpl.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65063 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 24102d0..b0ed13e 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,56 @@
+2010-08-10  Hans Wennborg  <hans at chromium.org>
+
+        Reviewed by Jeremy Orlow.
+
+        Implement chromium WebDeviceOrientationClient wrapper and have WebViewImpl get it from WebViewClient.
+        https://bugs.webkit.org/show_bug.cgi?id=43258
+
+        Provide a DeviceOrientationClient to Page by means of a
+        DeviceOrientationClientProxy that proxies calls to
+        a WebDeviceOrientationClient, an interface that can be implemented
+        in the WebKit or Chromium layer. An implementation to be used for
+        layout tests, wrapping DeviceOrientationClientMock, is provided.
+
+
+        * WebKit.gyp:
+        * public/WebDeviceOrientation.h: Added.
+        (WebKit::WebDeviceOrientation::WebDeviceOrientation):
+        * public/WebDeviceOrientationClient.h: Added.
+        (WebKit::WebDeviceOrientationClient::~WebDeviceOrientationClient):
+        * public/WebDeviceOrientationClientMock.h: Added.
+        (WebKit::WebDeviceOrientationClientMock::WebDeviceOrientationClientMock):
+        (WebKit::WebDeviceOrientationClientMock::~WebDeviceOrientationClientMock):
+        * public/WebDeviceOrientationController.h: Added.
+        (WebKit::WebDeviceOrientationController::WebDeviceOrientationController):
+        * public/WebViewClient.h:
+        (WebKit::WebViewClient::deviceOrientationClient):
+        * src/DeviceOrientationClientProxy.cpp: Added.
+        (WebKit::DeviceOrientationClientProxy::setController):
+        (WebKit::DeviceOrientationClientProxy::startUpdating):
+        (WebKit::DeviceOrientationClientProxy::stopUpdating):
+        (WebKit::DeviceOrientationClientProxy::lastOrientation):
+        * src/DeviceOrientationClientProxy.h: Added.
+        (WebKit::DeviceOrientationClientProxy::DeviceOrientationClientProxy):
+        * src/WebDeviceOrientation.cpp: Added.
+        (WebKit::WebDeviceOrientation::WebDeviceOrientation):
+        (WebKit::WebDeviceOrientation::operator=):
+        (WebKit::WebDeviceOrientation::operator PassRefPtr<WebCore::DeviceOrientation>):
+        * src/WebDeviceOrientationClientMock.cpp: Added.
+        (WebKit::WebDeviceOrientationClientMock::setController):
+        (WebKit::WebDeviceOrientationClientMock::startUpdating):
+        (WebKit::WebDeviceOrientationClientMock::stopUpdating):
+        (WebKit::WebDeviceOrientationClientMock::lastOrientation):
+        (WebKit::WebDeviceOrientationClientMock::setOrientation):
+        (WebKit::WebDeviceOrientationClientMock::initialize):
+        (WebKit::WebDeviceOrientationClientMock::reset):
+        * src/WebDeviceOrientationController.cpp: Added.
+        (WebKit::WebDeviceOrientationController::didChangeDeviceOrientation):
+        (WebKit::WebDeviceOrientationController::controller):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebView::create):
+        (WebKit::WebViewImpl::WebViewImpl):
+        * src/WebViewImpl.h:
+
 2010-08-10  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r64988.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index 06fd82c..eb5abbe 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -142,6 +142,10 @@
                 'public/WebDevToolsAgentClient.h',
                 'public/WebDevToolsFrontend.h',
                 'public/WebDevToolsFrontendClient.h',
+                'public/WebDeviceOrientation.h',
+                'public/WebDeviceOrientationClient.h',
+                'public/WebDeviceOrientationClientMock.h',
+                'public/WebDeviceOrientationController.h',
                 'public/WebDocument.h',
                 'public/WebDocumentType.h',
                 'public/WebDragData.h',
@@ -296,6 +300,8 @@
                 'src/DebuggerAgentImpl.h',
                 'src/DebuggerAgentManager.cpp',
                 'src/DebuggerAgentManager.h',
+                'src/DeviceOrientationClientProxy.cpp',
+                'src/DeviceOrientationClientProxy.h',
                 'src/DOMUtilitiesPrivate.cpp',
                 'src/DOMUtilitiesPrivate.h',
                 'src/DragClientImpl.cpp',
@@ -378,6 +384,9 @@
                 'src/WebDevToolsAgentImpl.h',
                 'src/WebDevToolsFrontendImpl.cpp',
                 'src/WebDevToolsFrontendImpl.h',
+                'src/WebDeviceOrientation.cpp',
+                'src/WebDeviceOrientationClientMock.cpp',
+                'src/WebDeviceOrientationController.cpp',
                 'src/WebDocument.cpp',
                 'src/WebDocumentType.cpp',
                 'src/WebDragData.cpp',
diff --git a/WebKit/chromium/public/WebDeviceOrientation.h b/WebKit/chromium/public/WebDeviceOrientation.h
new file mode 100644
index 0000000..7e8aa72
--- /dev/null
+++ b/WebKit/chromium/public/WebDeviceOrientation.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDeviceOrientation_h
+#define WebDeviceOrientation_h
+
+#if WEBKIT_IMPLEMENTATION
+namespace WTF { template <typename T> class PassRefPtr; }
+namespace WebCore { class DeviceOrientation; }
+#endif
+
+namespace WebKit {
+
+class WebDeviceOrientation {
+public:
+    WebDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
+        : m_isNull(false),
+          m_canProvideAlpha(canProvideAlpha),
+          m_alpha(alpha),
+          m_canProvideBeta(canProvideBeta),
+          m_beta(beta),
+          m_canProvideGamma(canProvideGamma),
+          m_gamma(gamma)
+    {
+    }
+
+    static WebDeviceOrientation nullOrientation() { return WebDeviceOrientation(); }
+
+    bool isNull() { return m_isNull; }
+    bool canProvideAlpha() { return m_canProvideAlpha; }
+    double alpha() { return m_alpha; }
+    bool canProvideBeta() { return m_canProvideBeta; }
+    double beta() { return m_beta; }
+    bool canProvideGamma() { return m_canProvideGamma; }
+    double gamma() { return m_gamma; }
+
+#if WEBKIT_IMPLEMENTATION
+    WebDeviceOrientation(const WTF::PassRefPtr<WebCore::DeviceOrientation>&);
+    WebDeviceOrientation& operator=(const WTF::PassRefPtr<WebCore::DeviceOrientation>&);
+    operator WTF::PassRefPtr<WebCore::DeviceOrientation>() const;
+#endif
+
+private:
+    WebDeviceOrientation()
+        : m_isNull(true),
+          m_canProvideAlpha(false),
+          m_alpha(0),
+          m_canProvideBeta(false),
+          m_beta(0),
+          m_canProvideGamma(false),
+          m_gamma(0)
+    {
+    }
+
+    bool m_isNull;
+    bool m_canProvideAlpha;
+    double m_alpha;
+    bool m_canProvideBeta;
+    double m_beta;
+    bool m_canProvideGamma;
+    double m_gamma;
+};
+
+} // namespace WebKit
+
+#endif // WebDeviceOrientation_h
diff --git a/WebKit/chromium/public/WebDeviceOrientationClient.h b/WebKit/chromium/public/WebDeviceOrientationClient.h
new file mode 100644
index 0000000..4df8665
--- /dev/null
+++ b/WebKit/chromium/public/WebDeviceOrientationClient.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDeviceOrientationClient_h
+#define WebDeviceOrientationClient_h
+
+namespace WebKit {
+
+class WebDeviceOrientation;
+class WebDeviceOrientationController;
+
+class WebDeviceOrientationClient {
+public:
+    virtual ~WebDeviceOrientationClient() {}
+
+    virtual void setController(WebDeviceOrientationController*) = 0;
+    virtual void startUpdating() = 0;
+    virtual void stopUpdating() = 0;
+
+    virtual WebDeviceOrientation lastOrientation() const = 0;
+};
+
+} // namespace WebKit
+
+#endif // WebDeviceOrientationClient_h
diff --git a/WebKit/chromium/public/WebDeviceOrientationClientMock.h b/WebKit/chromium/public/WebDeviceOrientationClientMock.h
new file mode 100644
index 0000000..fce964b
--- /dev/null
+++ b/WebKit/chromium/public/WebDeviceOrientationClientMock.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDeviceOrientationClientMock_h
+#define WebDeviceOrientationClientMock_h
+
+#include "WebCommon.h"
+#include "WebDeviceOrientationClient.h"
+
+namespace WebCore { class DeviceOrientationClientMock; }
+
+namespace WebKit {
+
+class WebDeviceOrientationClientMock : public WebDeviceOrientationClient {
+public:
+    WebDeviceOrientationClientMock() { initialize(); }
+    ~WebDeviceOrientationClientMock() { reset(); }
+
+    virtual void setController(WebDeviceOrientationController*);
+    virtual void startUpdating();
+    virtual void stopUpdating();
+    virtual WebDeviceOrientation lastOrientation() const;
+
+    WEBKIT_API void setOrientation(WebDeviceOrientation&);
+
+private:
+    WEBKIT_API void initialize();
+    WEBKIT_API void reset();
+
+    WebCore::DeviceOrientationClientMock* m_clientMock;
+};
+
+} // namespace WebKit
+
+#endif // WebDeviceOrientationClientMock_h
diff --git a/WebKit/chromium/public/WebDeviceOrientationController.h b/WebKit/chromium/public/WebDeviceOrientationController.h
new file mode 100644
index 0000000..ef843ee
--- /dev/null
+++ b/WebKit/chromium/public/WebDeviceOrientationController.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDeviceOrientationController_h
+#define WebDeviceOrientationController_h
+
+#include "WebCommon.h"
+
+namespace WebCore { class DeviceOrientationController; }
+
+namespace WebKit {
+
+class WebDeviceOrientation;
+
+class WebDeviceOrientationController {
+public:
+    WebDeviceOrientationController(WebCore::DeviceOrientationController* c)
+        : m_controller(c)
+    {
+    }
+
+    WEBKIT_API void didChangeDeviceOrientation(const WebDeviceOrientation&);
+
+#if WEBKIT_IMPLEMENTATION
+    WebCore::DeviceOrientationController* controller() const;
+#endif
+
+private:
+    WebCore::DeviceOrientationController* m_controller;
+};
+
+} // namespace WebKit
+
+#endif // WebDeviceOrientationController_h
diff --git a/WebKit/chromium/public/WebViewClient.h b/WebKit/chromium/public/WebViewClient.h
index 4628c2f..c64418b 100644
--- a/WebKit/chromium/public/WebViewClient.h
+++ b/WebKit/chromium/public/WebViewClient.h
@@ -44,6 +44,7 @@
 namespace WebKit {
 
 class WebAccessibilityObject;
+class WebDeviceOrientationClient;
 class WebDragData;
 class WebElement;
 class WebFileChooserCompletion;
@@ -341,6 +342,11 @@ public:
     virtual WebSpeechInputController* speechInputController(
         WebSpeechInputListener*) { return 0; }
 
+    // Device Orientation --------------------------------------------------
+
+    // Access the embedder API for device orientation services.
+    virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; }
+
 protected:
     ~WebViewClient() { }
 };
diff --git a/WebKit/chromium/src/DeviceOrientationClientProxy.cpp b/WebKit/chromium/src/DeviceOrientationClientProxy.cpp
new file mode 100644
index 0000000..f4a0dd9
--- /dev/null
+++ b/WebKit/chromium/src/DeviceOrientationClientProxy.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DeviceOrientationClientProxy.h"
+
+#include "DeviceOrientation.h"
+#include "WebDeviceOrientation.h"
+#include "WebDeviceOrientationController.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class DeviceOrientationController;
+}
+
+namespace WebKit {
+
+void DeviceOrientationClientProxy::setController(WebCore::DeviceOrientationController* c)
+{
+    if (!m_client) // FIXME: Get rid of these null checks once device orientation is enabled by default.
+        return;
+    m_client->setController(new WebDeviceOrientationController(c));
+}
+
+void DeviceOrientationClientProxy::startUpdating()
+{
+    if (!m_client)
+        return;
+    m_client->startUpdating();
+}
+
+void DeviceOrientationClientProxy::stopUpdating()
+{
+    if (!m_client)
+        return;
+    m_client->stopUpdating();
+}
+
+WebCore::DeviceOrientation* DeviceOrientationClientProxy::lastOrientation() const
+{
+    if (!m_client)
+        return 0;
+
+    // Cache the DeviceOrientation pointer so its reference count does not drop to zero upon return.
+    m_lastOrientation = m_client->lastOrientation();
+
+    return m_lastOrientation.get();
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/DeviceOrientationClientProxy.h b/WebKit/chromium/src/DeviceOrientationClientProxy.h
new file mode 100644
index 0000000..2d3a7dc
--- /dev/null
+++ b/WebKit/chromium/src/DeviceOrientationClientProxy.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DeviceOrientationClientProxy_h
+#define DeviceOrientationClientProxy_h
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClient.h"
+#include "WebDeviceOrientationClient.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class DeviceOrientationController;
+}
+
+namespace WebKit {
+
+class DeviceOrientationClientProxy : public WebCore::DeviceOrientationClient {
+public:
+    DeviceOrientationClientProxy(WebDeviceOrientationClient* client)
+        : m_client(client)
+    {
+    }
+
+    void setController(WebCore::DeviceOrientationController*);
+    void startUpdating();
+    void stopUpdating();
+    WebCore::DeviceOrientation* lastOrientation() const;
+
+private:
+    WebDeviceOrientationClient* m_client;
+    mutable RefPtr<WebCore::DeviceOrientation> m_lastOrientation;
+};
+
+} // namespace WebKit
+
+#endif // DeviceOrientationClientProxy_h
diff --git a/WebKit/chromium/src/WebDeviceOrientation.cpp b/WebKit/chromium/src/WebDeviceOrientation.cpp
new file mode 100644
index 0000000..47f6bd1
--- /dev/null
+++ b/WebKit/chromium/src/WebDeviceOrientation.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDeviceOrientation.h"
+
+#include "DeviceOrientation.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+WebDeviceOrientation::WebDeviceOrientation(const PassRefPtr<WebCore::DeviceOrientation>& orientation)
+{
+    if (!orientation) {
+        m_isNull = true;
+        m_canProvideAlpha = false;
+        m_alpha = 0;
+        m_canProvideBeta = false;
+        m_beta = 0;
+        m_canProvideGamma = false;
+        m_gamma = 0;
+        return;
+    }
+
+    m_isNull = false;
+    m_canProvideAlpha = orientation->canProvideAlpha();
+    m_alpha = orientation->alpha();
+    m_canProvideBeta = orientation->canProvideBeta();
+    m_beta = orientation->beta();
+    m_canProvideGamma = orientation->canProvideGamma();
+    m_gamma = orientation->gamma();
+}
+
+WebDeviceOrientation& WebDeviceOrientation::operator=(const PassRefPtr<WebCore::DeviceOrientation>& orientation)
+{
+    if (!orientation) {
+        m_isNull = true;
+        m_canProvideAlpha = false;
+        m_alpha = 0;
+        m_canProvideBeta = false;
+        m_beta = 0;
+        m_canProvideGamma = false;
+        m_gamma = 0;
+        return *this;
+    }
+
+    m_isNull = false;
+    m_canProvideAlpha = orientation->canProvideAlpha();
+    m_alpha = orientation->alpha();
+    m_canProvideBeta = orientation->canProvideBeta();
+    m_beta = orientation->beta();
+    m_canProvideGamma = orientation->canProvideGamma();
+    m_gamma = orientation->gamma();
+    return *this;
+}
+
+WebDeviceOrientation::operator PassRefPtr<WebCore::DeviceOrientation>() const
+{
+    if (m_isNull)
+        return 0;
+    return WebCore::DeviceOrientation::create(m_canProvideAlpha, m_alpha, m_canProvideBeta, m_beta, m_canProvideGamma, m_gamma);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp b/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp
new file mode 100644
index 0000000..4011d12
--- /dev/null
+++ b/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDeviceOrientationClientMock.h"
+
+#include "DeviceOrientationClientMock.h"
+#include "WebDeviceOrientation.h"
+#include "WebDeviceOrientationController.h"
+
+namespace WebKit {
+
+void WebDeviceOrientationClientMock::setController(WebDeviceOrientationController* controller)
+{
+    m_clientMock->setController(controller->controller());
+}
+
+void WebDeviceOrientationClientMock::startUpdating()
+{
+    m_clientMock->startUpdating();
+}
+
+void WebDeviceOrientationClientMock::stopUpdating()
+{
+    m_clientMock->stopUpdating();
+}
+
+WebDeviceOrientation WebDeviceOrientationClientMock::lastOrientation() const
+{
+    return WebDeviceOrientation(m_clientMock->lastOrientation());
+}
+
+void WebDeviceOrientationClientMock::setOrientation(WebDeviceOrientation& orientation)
+{
+    m_clientMock->setOrientation(orientation);
+}
+
+void WebDeviceOrientationClientMock::initialize()
+{
+    m_clientMock = new WebCore::DeviceOrientationClientMock();
+}
+
+void WebDeviceOrientationClientMock::reset()
+{
+    delete m_clientMock;
+    m_clientMock = 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebDeviceOrientationController.cpp b/WebKit/chromium/src/WebDeviceOrientationController.cpp
new file mode 100644
index 0000000..aa9249f
--- /dev/null
+++ b/WebKit/chromium/src/WebDeviceOrientationController.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDeviceOrientationController.h"
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationController.h"
+#include "WebDeviceOrientation.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+void WebDeviceOrientationController::didChangeDeviceOrientation(const WebDeviceOrientation& orientation)
+{
+    PassRefPtr<WebCore::DeviceOrientation> deviceOrientation(orientation);
+    m_controller->didChangeDeviceOrientation(deviceOrientation.get());
+}
+
+WebCore::DeviceOrientationController* WebDeviceOrientationController::controller() const
+{
+    return m_controller;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index d9baacd..8733a2a 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -41,6 +41,7 @@
 #include "CSSStyleSelector.h"
 #include "CSSValueKeywords.h"
 #include "Cursor.h"
+#include "DeviceOrientationClientProxy.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "DOMUtilitiesPrivate.h"
@@ -177,9 +178,8 @@ static const PopupContainerSettings autoFillPopupSettings = {
 
 WebView* WebView::create(WebViewClient* client, WebDevToolsAgentClient* devToolsClient)
 {
-    // Keep runtime flag for device orientation turned off until it's implemented.
+    // Keep runtime flag for device motion turned off until it's implemented.
     WebRuntimeFeatures::enableDeviceMotion(false);
-    WebRuntimeFeatures::enableDeviceOrientation(false);
 
     // Pass the WebViewImpl's self-reference to the caller.
     return adoptRef(new WebViewImpl(client, devToolsClient)).leakRef();
@@ -267,6 +267,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools
     , m_speechInputClient(client)
 #endif
     , m_gles2Context(0)
+    , m_deviceOrientationClientProxy(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))
 {
     // WebKit/win/WebView.cpp does the same thing, except they call the
     // KJS specific wrapper around this method. We need to have threading
@@ -289,9 +290,9 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools
 #if ENABLE(INPUT_SPEECH)
     pageClients.speechInputClient = &m_speechInputClient;
 #endif
-    m_page.set(new Page(pageClients));
+    pageClients.deviceOrientationClient = m_deviceOrientationClientProxy.get();
 
-    // the page will take ownership of the various clients
+    m_page.set(new Page(pageClients));
 
     m_page->backForwardList()->setClient(&m_backForwardListClientImpl);
     m_page->setGroupName(pageGroupName);
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 4f2a60b..c296121 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -71,6 +71,7 @@ namespace WebKit {
 class AutocompletePopupMenuClient;
 class AutoFillPopupMenuClient;
 class ContextMenuClientImpl;
+class DeviceOrientationClientProxy;
 class DragScrollTimer;
 class WebAccessibilityObject;
 class WebDevToolsAgentClient;
@@ -519,6 +520,8 @@ private:
 #endif
 
     OwnPtr<WebGLES2Context> m_gles2Context;
+
+    OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
 };
 
 } // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list