OSDN Git Service

Enable orientation events.
authorPatrick Scott <phanna@android.com>
Wed, 2 Dec 2009 13:32:13 +0000 (08:32 -0500)
committerPatrick Scott <phanna@android.com>
Wed, 9 Dec 2009 17:36:31 +0000 (12:36 -0500)
Remove our old orientation hacks as webkit now supports the orientation event.
Call down into webkit when the orientation changes to send the js event.

The change to Frame.cpp has been submited to bugs.webkit.org as issue 32321.

JavaScriptCore/wtf/Platform.h
WebCore/Android.derived.jscbindings.mk
WebCore/Android.derived.v8bindings.mk
WebCore/config.h
WebCore/page/DOMWindow.cpp
WebCore/page/DOMWindow.h
WebCore/page/DOMWindow.idl
WebCore/page/Frame.cpp
WebCore/page/Screen.h
WebCore/platform/android/ScreenAndroid.cpp
WebKit/android/jni/WebCoreFrameBridge.cpp

index 888f6a8..20c030b 100644 (file)
 // This prevents unnecessary invals.
 #define ENABLE_TEXT_CARET 1
 #define ENABLE_JAVASCRIPT_DEBUGGER 0
+#define ENABLE_ORIENTATION_EVENTS 1
 #endif
 
 #if PLATFORM(WIN)
index 88bf830..2eb19f5 100644 (file)
@@ -49,7 +49,7 @@ js_binding_scripts := $(addprefix $(LOCAL_PATH)/,\
                        bindings/scripts/generate-bindings.pl \
                )
 
-FEATURE_DEFINES := ANDROID_ORIENTATION_SUPPORT ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_WORKERS=1 ENABLE_GEOLOCATION=1 ENABLE_CHANNEL_MESSAGING=1
+FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_WORKERS=1 ENABLE_GEOLOCATION=1 ENABLE_CHANNEL_MESSAGING=1
 
 # CSS
 GEN := \
index 015aab6..e0b5d98 100644 (file)
@@ -30,7 +30,7 @@ js_binding_scripts := \
        $(LOCAL_PATH)/bindings/scripts/IDLStructure.pm \
        $(LOCAL_PATH)/bindings/scripts/generate-bindings.pl
 
-FEATURE_DEFINES := ANDROID_ORIENTATION_SUPPORT ENABLE_TOUCH_EVENTS=1 V8_BINDING ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_WORKERS=1 ENABLE_GEOLOCATION=1
+FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 V8_BINDING ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_WORKERS=1 ENABLE_GEOLOCATION=1
 
 # CSS
 GEN := \
index 127d1cb..19b60c8 100644 (file)
 // PLUGIN_SCHEDULE_TIMER)
 #define ANDROID_PLUGINS
 
-// Add support for the orientation window property
-#define ANDROID_ORIENTATION_SUPPORT
-
 // This enables a portable implementation of NPN_[Un]ScheduleTimer
 // Will submit this as a patch to apple
 #define PLUGIN_SCHEDULE_TIMER
index 64aae8d..8452e55 100644 (file)
@@ -914,13 +914,6 @@ int DOMWindow::scrollX() const
     return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
 }
 
-#ifdef ANDROID_ORIENTATION_SUPPORT
-int DOMWindow::orientation() const
-{
-    return screen()->orientation();
-}
-#endif
-
 int DOMWindow::scrollY() const
 {
     if (!m_frame)
index c116f5b..235c9a0 100644 (file)
@@ -154,9 +154,6 @@ namespace WebCore {
         int scrollY() const;
         int pageXOffset() const { return scrollX(); }
         int pageYOffset() const { return scrollY(); }
-#ifdef ANDROID_ORIENTATION_SUPPORT
-        int orientation() const;
-#endif
 
         bool closed() const;
 
index dfafa35..c7bcf82 100644 (file)
@@ -106,9 +106,6 @@ module window {
         attribute [Replaceable] long scrollY;
         readonly attribute long pageXOffset;
         readonly attribute long pageYOffset;
-#if defined(ANDROID_ORIENTATION_SUPPORT)
-        attribute [Replaceable] long orientation;
-#endif
 
         [RequiresAllArguments] void scrollBy(in long x, in long y);
         [RequiresAllArguments] void scrollTo(in long x, in long y);
index dac6553..b9bf94e 100644 (file)
@@ -296,7 +296,7 @@ void Frame::sendOrientationChangeEvent(int orientation)
 {
     m_orientation = orientation;
     if (Document* doc = document())
-        doc->dispatchWindowEvent(eventNames().orientationchangeEvent, false, false);
+        doc->dispatchWindowEvent(Event::create(eventNames().orientationchangeEvent, false, false));
 }
 #endif // ENABLE(ORIENTATION_EVENTS)
     
index 6f34195..2c84abd 100644 (file)
@@ -52,9 +52,6 @@ namespace WebCore {
         unsigned availTop() const;
         unsigned availHeight() const;
         unsigned availWidth() const;
-#ifdef ANDROID_ORIENTATION_SUPPORT
-        int orientation() const;
-#endif
 
     private:
         Screen(Frame*);
index 881c246..ad6e008 100644 (file)
@@ -60,32 +60,6 @@ bool screenIsMonochrome(Widget* page)
     return false;
 }
 
-#ifdef ANDROID_ORIENTATION_SUPPORT
-int Screen::orientation() const
-{
-    android::DisplayInfo info;
-    android::SurfaceComposerClient::getDisplayInfo(
-            android::DisplayID(0), &info);
-    // getDisplayInfo returns an enum describing the orientation. Map the enum
-    // to the values described here
-    // (http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/chapter_8_section_6.html)
-    switch (info.orientation) {
-    case android::ISurfaceComposer::eOrientationDefault:
-        return 0;
-    case android::ISurfaceComposer::eOrientation90:
-        return 90;
-    case android::ISurfaceComposer::eOrientation180:
-        return 180;
-    case android::ISurfaceComposer::eOrientation270:
-        return -90;
-    default:
-        LOGE("Bad orientation returned from getDisplayIndo %d",
-                info.orientation);
-        return 0;
-    }
-}
-#endif
-
 // The only place I have seen these values used is
 // positioning popup windows. If we support multiple windows
 // they will be most likely full screen. Therefore,
index c420b4c..646c5b8 100644 (file)
@@ -1487,6 +1487,16 @@ static jobject GetFormTextData(JNIEnv *env, jobject obj)
     return hashMap;
 }
 
+static void OrientationChanged(JNIEnv *env, jobject obj, int orientation)
+{
+#ifdef ANDROID_INSTRUMENT
+    TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
+#endif
+    WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
+    LOGE("Sending orientation: %d", orientation);
+    pFrame->sendOrientationChangeEvent(orientation);
+}
+
 // ----------------------------------------------------------------------------
 
 /*
@@ -1536,7 +1546,9 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
     { "setUsernamePassword", "(Ljava/lang/String;Ljava/lang/String;)V",
         (void*) SetUsernamePassword },
     { "getFormTextData", "()Ljava/util/HashMap;",
-        (void*) GetFormTextData }
+        (void*) GetFormTextData },
+    { "nativeOrientationChanged", "(I)V",
+        (void*) OrientationChanged }
 };
 
 int register_webframe(JNIEnv* env)