Fix the problem that the screen of the application does not rotation automatically.
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / PageClientImpl.cpp
index cb4b861..0c28a54 100755 (executable)
@@ -104,6 +104,7 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
     , m_scrollPositionBeforePageRendered(IntPoint())
 #endif
     , m_isVisible(true)
+    , m_deferUpdateViewportSize(false)
     , m_isScrollableLayerFocused(false)
     , m_isScrollableNodeFocused(false)
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
@@ -116,6 +117,7 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
     , m_waitFrameOfNewViewortSize(false)
 #endif
+    , m_nonemptyLayoutRendered(false)
 #endif // #if OS(TIZEN)
 {
 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
@@ -192,13 +194,24 @@ void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int a
 #if ENABLE(TIZEN_DLOG_SUPPORT)
     TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle);
 #endif
+#if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
+    if (m_deferUpdateViewportSize) {
+        m_visibleContentRect.setSize(viewportSize);
+        m_viewImpl->page()->setViewportSize(viewportSize);
+        m_deferUpdateViewportSize = false;
+        return;
+    }
+#endif
 
     // update viewport size of webkit
-    m_visibleContentRect.setSize(viewportSize);
-    m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
-    m_viewImpl->setScrollPosition(m_visibleContentRect.location());
     m_viewImpl->page()->setViewportSize(viewportSize);
 }
+
+void PageClientImpl::updateVisibleContentRectSize(const IntSize& size)
+{
+    // update visible content rect's size
+    m_visibleContentRect.setSize(size);
+}
 #endif
 
 void PageClientImpl::prepareRestoredVisibleContectRect()
@@ -396,6 +409,10 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
     double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
     m_viewportConstraints = computeViewportConstraints(attributes);
 
+#if ENABLE(TIZEN_GESTURE)
+    m_viewImpl->setDoubleTapEnabled(userScalable());
+#endif
+
     // Initially, m_scaleFactor is not decided yet.
     // So, we should update visible content rect at here.
     if (!m_scaleFactor) {
@@ -437,6 +454,8 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
     if (isRotated) {
         m_viewportAngle = angle;
         newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
+        if (m_viewportFitsToContent)
+            newScale = m_viewportConstraints.minimumScale;
         newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
     }
 
@@ -661,6 +680,7 @@ void PageClientImpl::didChangeScrollbarsForMainFrame() const
 #if OS(TIZEN)
 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
 {
+    m_nonemptyLayoutRendered = true;
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
     m_initialViewRect.setSize(viewSize());
 #endif
@@ -721,6 +741,7 @@ void PageClientImpl::didCommitLoadForMainFrame(bool)
 #if OS(TIZEN)
     m_pageDidRendered = false;
     m_viewportFitsToContent = false;
+    m_nonemptyLayoutRendered = false;
     return;
 #endif
     notImplemented();
@@ -788,9 +809,6 @@ void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
     IntPoint newPoint = point;
     newPoint.scale(scaleFactor(), scaleFactor());
 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
-#if ENABLE(TIZEN_DLOG_SUPPORT)
-    TIZEN_LOGI("scroll position: [%d, %d], [%s]", newPoint.x(), newPoint.y(), m_pageDidRendered ? "Rendered" : "Before rendered");
-#endif
     if (!m_pageDidRendered)
         m_scrollPositionBeforePageRendered = newPoint;
     else
@@ -913,7 +931,7 @@ void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScal
     displayViewport();
 
 #if ENABLE(TIZEN_SCREEN_READER)
-    if (ScreenReaderProxy::screenReader().isEnabled()
+    if (ScreenReaderProxy::screenReader().isActive(m_viewImpl)
         && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
         ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
 #endif
@@ -1123,7 +1141,7 @@ void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool
         m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
 }
 
-bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
+bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point)
 {
     if (!evas_object_focus_get(m_viewImpl->view())) {
         InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
@@ -1133,12 +1151,12 @@ bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isSt
         evas_object_focus_set(m_viewImpl->view(), true);
     }
 
-    return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
+    return m_textSelection->textSelectionDown(point);
 }
 
-void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
+void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point)
 {
-    m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
+    m_textSelection->textSelectionMove(point);
 }
 
 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
@@ -1292,7 +1310,7 @@ void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBit
     String dragStorageName("Drag");
     m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
     setDragMode(true);
-    m_drag->setDragData(dragInfo);
+    m_drag->setDragData(dragInfo, dragImage);
     m_drag->Show();
 }
 #endif
@@ -1437,47 +1455,6 @@ void PageClientImpl::findScrollableNode(const IntPoint& point)
 }
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
-{
-    WebCore::IntPoint startPoint, endPoint;
-    WebCore::IntRect leftRect, rightRect;
-
-    WebCore::IntRect caretRect;
-    m_viewImpl->page()->getCaretPosition(caretRect);
-    if (!caretRect.isEmpty()) {
-        startPoint.setX(caretRect.x());
-        startPoint.setY(caretRect.y() + caretRect.height());
-
-        endPoint.setX(caretRect.x() + caretRect.width());
-        endPoint.setY(caretRect.y() + caretRect.height());
-    }
-#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-    else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
-        startPoint.setX(leftRect.x());
-        startPoint.setY(leftRect.y() + leftRect.height());
-
-        endPoint.setX(rightRect.x() + rightRect.width());
-        endPoint.setY(rightRect.y() + rightRect.height());
-    }
-#endif
-
-    startPoint.scale(scaleFactor(), scaleFactor());
-    endPoint.scale(scaleFactor(), scaleFactor());
-
-    int viewPositionX, viewPositionY;
-    evas_object_geometry_get(m_viewImpl->view(), &viewPositionX, &viewPositionY, NULL, NULL);
-
-    startPoint.move(-scrollPosition().x(),  -scrollPosition().y());
-    startPoint.move(viewPositionX, viewPositionY);
-
-    endPoint.move(-scrollPosition().x(),  -scrollPosition().y());
-    endPoint.move(viewPositionX, viewPositionY);
-
-    ewkViewDidGetTextStyleStateForSelection(m_viewImpl->view(), underlineState, italicState, boldState, startPoint, endPoint);
-}
-#endif
-
 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
 {
     ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
@@ -1523,13 +1500,18 @@ PageClientEvasGL::~PageClientEvasGL()
 
 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
 {
+    PageClientImpl::updateViewportSize(viewportSize, angle);
+}
+
+void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size)
+{
     if (m_surface) {
         evas_gl_surface_destroy(m_evasGL, m_surface);
         m_surface = 0;
     }
     setTargetSurface();
 
-    PageClientImpl::updateViewportSize(viewportSize, angle);
+    PageClientImpl::updateVisibleContentRectSize(size);
 }
 
 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)