Sync onorientationchange and onresize event
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / WebPage.cpp
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);