Sync onorientationchange and onresize event
authorChanghyup Jwa <ch.jwa@samsung.com>
Mon, 12 Aug 2013 13:18:49 +0000 (22:18 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 14 Oct 2013 03:02:01 +0000 (03:02 +0000)
[Title] Sync onorientationchange and onresize event
[Issue#] DCM-2318
[Problem] JS window.innerWidth and innerHeight returns incorrect value on
        orientation changed event
[Cause] JS values are not set yet
[Solution] Dispatch onorientationchanged event after JS values are set

Change-Id: I64fe68ec31106cf5bac918df793f3939122e8902

Source/WebKit2/UIProcess/API/efl/ewk_view.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h

index f54a097..914657e 100755 (executable)
@@ -1265,8 +1265,8 @@ EAPI Eina_Bool ewk_view_notification_closed(Evas_Object* o, Eina_List* notificat
  * @param orientation the new orientation of the device. (degree)
  *
  * orientation will be 0 degrees when the device is oriented to natural position,
- *                     90 degrees when it's left side is at the top,
- *                    -90 degrees when it's right side is at the top,
+ *                     -90 degrees when it's left side is at the top,
+ *                     90 degrees when it's right side is at the top,
  *                     180 degrees when it is upside down.
  */
 EAPI void ewk_view_orientation_send(Evas_Object *o, int orientation);
index 4421d23..eb4843b 100755 (executable)
@@ -306,6 +306,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , m_prepareKeyDownEvent(false)
     , m_recalcFilterEvent(false)
 #endif
+#if ENABLE(TIZEN_ORIENTATION_EVENTS)
+    , m_newOrientation(-1)
+#endif
 {
     ASSERT(m_pageID);
     // FIXME: This is a non-ideal location for this Setting and
@@ -1135,6 +1138,15 @@ void WebPage::sendViewportAttributesChanged()
         attr.initialScale = ViewportArguments::ValueAuto;
 #endif
 
+#if ENABLE(TIZEN_ORIENTATION_EVENTS)
+    if (m_mainFrame->coreFrame() && m_newOrientation != -1) {
+        m_mainFrame->coreFrame()->sendOrientationChangeEvent(m_newOrientation);
+        for (WebCore::Frame* child = m_mainFrame->coreFrame()->tree()->firstChild(); child; child = child->tree()->nextSibling())
+            child->sendOrientationChangeEvent(m_newOrientation);
+        m_newOrientation = -1;
+    }
+#endif
+
     setResizesToContentsUsingLayoutSize(IntSize(static_cast<int>(attr.layoutSize.width()), static_cast<int>(attr.layoutSize.height())));
 
 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
@@ -1268,6 +1280,15 @@ void WebPage::sendOrientationChangeEvent(int newOrientation)
     if (!frame || frame->orientation() == newOrientation)
         return;
 
+    // If it's rotated 90 or -90 degrees,
+    // orientation change event will be fired on WebPage::sendViewportAttributesChanged
+    if (fabs(frame->orientation() - newOrientation) != 180) {
+        m_newOrientation = newOrientation;
+        return;
+    }
+
+    // If it's rotated 180 degrees, ewk_view will not be resized
+    // So, fire orientation change event here
     frame->sendOrientationChangeEvent(newOrientation);
     for (WebCore::Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
         child->sendOrientationChangeEvent(newOrientation);
index 1f3c89a..e611d49 100755 (executable)
@@ -1236,6 +1236,10 @@ private:
     Vector<OwnPtr<KeyPressCommand> > m_keyPressCommands;
     bool m_recalcFilterEvent;
 #endif
+
+#if ENABLE(TIZEN_ORIENTATION_EVENTS)
+    int m_newOrientation;
+#endif
 };
 
 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)