X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=Source%2FWebKit2%2FUIProcess%2FAPI%2Fefl%2FPageClientImpl.cpp;h=b9d11a18f33eb4bd508826dd0ad2b6883e77a7fb;hb=ae00234efe0a9f7cbfab65e575ebfa67afffbfdd;hp=5e7477a997066b1de51a5f2cdc6522461ad4da02;hpb=0d93346c4626332b6e070b57fbf9b80b1c328a17;p=framework%2Fweb%2Fwebkit-efl.git diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 5e7477a..b9d11a1 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -89,16 +89,22 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl) , m_viewportConstraints() , m_viewFocused(false) , m_viewWindowActive(true) - , m_pageDidRendered(false) + , m_pageDidRendered(true) + , m_viewportAngle(0) + , m_viewportFitsToContent(false) #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) , m_visibleContentRect(IntRect()) - , m_scaleFactor(1.0f) + , m_scaleFactor(0) , m_hasSuspendedContent(false) #endif #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT) , m_restoredScaleFactor(0) #endif +#if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION) + , 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) @@ -108,6 +114,10 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl) #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2) , m_isContextMenuVisible(false) #endif +#if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION) + , m_waitFrameOfNewViewortSize(false) +#endif + , m_nonemptyLayoutRendered(false) #endif // #if OS(TIZEN) { #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING) @@ -131,6 +141,8 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl) #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE) m_formDataCandidate = FormDataCandidate::create(m_viewImpl); #endif + Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view())); + m_viewportAngle = ecore_evas_rotation_get(ee); #endif setBackgroundColor(1, 1, 1, 1); @@ -138,7 +150,8 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl) PageClientImpl::~PageClientImpl() { - m_viewImpl->page()->close(); + if (m_viewImpl && m_viewImpl->page()) + m_viewImpl->page()->close(); } #if OS(TIZEN) @@ -151,60 +164,65 @@ PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(c constraints.layoutSize = attributes.layoutSize; constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale); - double defaultViewLevel = m_viewImpl->page()->pageGroup()->preferences()->defaultViewLevel(); - // If defaultViewLevel is 1, "Default View" is set as "Readable" - // if not, "Default View" is set as "Fit to width" - if (defaultViewLevel) { + bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled(); + if (autoFittingEnabled) + constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio; + else { // if content doesn't set initial scale value, set readable scale factor // if not, set initial scale factor of viewport attribute if (attributes.initialScale == ViewportArguments::ValueAuto) constraints.initialScale = m_viewImpl->page()->deviceScaleFactor(); else constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio; - } else { - // Minimize initial scale factor - constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio; } // adjust scale with both minimum and maximum scale factor - constraints.initialScale = clampTo(constraints.initialScale, constraints.minimumScale, constraints.maximumScale); + constraints.initialScale = adjustScaleWithViewport(constraints.initialScale); return constraints; } double PageClientImpl::adjustScaleWithViewport(double scale) { - return clampTo(scale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale); + double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale); + return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale); } #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) -void PageClientImpl::updateViewportSize(const IntSize& viewportSize) +void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle) { - // update device width & height - int deviceWidth = WebCore::getDefaultScreenResolution().width(); - int deviceHeight = WebCore::getDefaultScreenResolution().height(); - Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view())); - int angle = ecore_evas_rotation_get(ee); - if (angle == 90 || angle == 270) { - int tempWidth = deviceWidth; - deviceWidth = deviceHeight; - deviceHeight = tempWidth; +#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; } - m_viewImpl->page()->pageGroup()->preferences()->setDeviceWidth(deviceWidth); - m_viewImpl->page()->pageGroup()->preferences()->setDeviceHeight(deviceHeight); +#endif // update viewport size of webkit - m_visibleContentRect.setSize(viewportSize); - - // Update visible content rect before resize viewport - // setVisibleContentRect() should be called once at here or ewk_view_focused_node_adjust() - if (!ewk_view_focused_node_adjust(m_viewImpl->view()) && m_pageDidRendered) - setVisibleContentRect(m_visibleContentRect, scaleFactor()); - 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() +{ + m_restoredScaleFactor = scaleFactor(); + m_restoredScrollPosition = scrollPosition(); +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor); +#endif +} + void PageClientImpl::initializeVisibleContentRect() { _ewk_view_resume_painting(m_viewImpl->view()); @@ -212,6 +230,10 @@ void PageClientImpl::initializeVisibleContentRect() #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) IntPoint initialScrollPosition; float initialScaleFactor = m_viewportConstraints.initialScale; +#if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION) + initialScrollPosition = m_scrollPositionBeforePageRendered; + m_scrollPositionBeforePageRendered = IntPoint(); +#endif #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT) // if scroll position and scale factor are restored by history controller, // move scroll position and scale factor with them @@ -219,6 +241,12 @@ void PageClientImpl::initializeVisibleContentRect() initialScrollPosition = m_restoredScrollPosition; initialScaleFactor = m_restoredScaleFactor; } +#if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT) + m_restoredScaleFactor = 0; +#endif +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", initialScrollPosition.x(), initialScrollPosition.y(), initialScaleFactor); +#endif #endif setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor); #else @@ -227,6 +255,29 @@ void PageClientImpl::initializeVisibleContentRect() #endif } +double PageClientImpl::availableMinimumScale() +{ + // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true. + // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level) + IntSize contentsSize = m_viewImpl->page()->contentsSize(); + double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25); + double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25); + // If there's only a bit ignorable difference between horizontalMinScale and verticalMinScale, + // ignore verticalMinScale to fit content's width to view + const double ignorableThreshold = 0.01; + if (fabs(horizontalMinScale - verticalMinScale) < ignorableThreshold) + verticalMinScale = horizontalMinScale; + return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale); +} + +void PageClientImpl::fitViewportToContent() +{ +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), m_viewportConstraints.minimumScale); +#endif + setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale); +} + void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect) { m_focusedNodeRect = focusedNodeRect; @@ -355,37 +406,83 @@ void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves) void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes) { - float prevMinimumScale = m_viewportConstraints.minimumScale; + double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale; m_viewportConstraints = computeViewportConstraints(attributes); - // setVisibleContentRect() is called to adjust visible content rect after device rotation - // In below cases, it shouldn't be called - // 1. page is not rendered yet - // 2. viewport attributes are changed by WebCore's empty document(progress == 0.1) - // 3. there's no input field zoom(device rotation without IME) - if (m_pageDidRendered && m_viewImpl->page()->estimatedProgress() > 0.1 && !ewk_view_focused_node_adjust(m_viewImpl->view())) { - IntSize contentsSize = m_viewImpl->page()->contentsSize(); - double minimumScaleByContentWidth = max(((double)viewSize().width() / contentsSize.width()), 0.25); - float newScale = scaleFactor(); - - // If contents width exceeds viewport layout width and content is userScalable, update minimumScale. - if (m_viewportConstraints.userScalable) - m_viewportConstraints.minimumScale = minimumScaleByContentWidth; - - // If zoom was fitted to width before the rotation, newScale should be fitted to width again. - if (fabs(scaleFactor() - prevMinimumScale) < numeric_limits::epsilon()) + +#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) { + setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale); + return; + } + + // if content is reloaded, contents size will not be changed + // so, we need to calculate minimum scale here. + // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize() + if (m_viewportConstraints.userScalable) { + if (fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits::epsilon()) + m_viewportConstraints.initialScale = availableMinimumScale(); + m_viewportConstraints.minimumScale = availableMinimumScale(); + } + +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("layout size: [%d, %d], scale: [%.2f, %.2f, %.2f], user scalable: [%s]", + m_viewportConstraints.layoutSize.width(), m_viewportConstraints.layoutSize.height(), + m_viewportConstraints.initialScale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale, + m_viewportConstraints.userScalable ? "TRUE" : "FALSE"); +#endif + + // setVisibleContentRect() should be called to adjust visible content rect only when view is resized + if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1) + return; + + // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust() + if (ewk_view_focused_node_adjust(m_viewImpl->view())) + return; + + float newScale = scaleFactor(); + IntPoint newScrollPosition = m_visibleContentRect.location(); + Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view())); + int angle = ecore_evas_rotation_get(ee); + bool isRotated = (angle != m_viewportAngle); + + // if it's rotated, we need to fit content to viewport by minimize the scale + 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); + } + +#if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION) + if (m_waitFrameOfNewViewortSize) + ewk_view_resume(m_viewImpl->view()); +#endif +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated"); +#endif + #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) - setVisibleContentRect(m_visibleContentRect, newScale); + setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale); #else - m_viewImpl->page()->scalePage(newScale, m_visibleContentRect.location()); + m_viewImpl->page()->scalePage(newScale, newScrollPosition); #endif - } #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE) Ewk_View_Smart_Data* smartData = static_cast(evas_object_smart_data_get(m_viewImpl->view())); if (smartData->api->formdata_candidate_is_showing(smartData)) smartData->api->formdata_candidate_hide(smartData); #endif + +#if ENABLE(TIZEN_FULLSCREEN_API) + if (m_viewImpl->page()->fullScreenManager()->isFullScreen()) + m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle(); +#endif } #if OS(TIZEN) @@ -583,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 @@ -590,6 +688,9 @@ void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame() void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size) { +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI(" [%d, %d]", size.width(), size.height()); +#endif #if USE(TILED_BACKING_STORE) if (size.isEmpty()) return; @@ -599,35 +700,34 @@ void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size) drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height())); #endif - // But we should recalculate this when viewport argument's minimum scale is not fixed. - // if contents' width exceeds viewport layout width and userScalable is true. - // And minimumScaleByContentWidth shouldn't be smaller than 0.25(minimum zoom level) - double oldMinimumScale = m_viewportConstraints.minimumScale; - double newMinimumScale = max(((double)viewSize().width() / size.width()), 0.25); - bool isMinimized = fabs(scaleFactor() - oldMinimumScale) < numeric_limits::epsilon(); - // if minimum scale factor is changed, update minimumScale. - if (m_viewportConstraints.userScalable - && fabs(oldMinimumScale - newMinimumScale) > numeric_limits::epsilon()) { + if (m_viewportConstraints.userScalable) { + double minimumScale = availableMinimumScale(); + // Sometimes initializeVisibleContentRect can be called after content size change. // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too. if (!m_viewportConstraints.contentsDefinedInitialScale - && fabs(m_viewportConstraints.initialScale - oldMinimumScale) < numeric_limits::epsilon()) - m_viewportConstraints.initialScale = newMinimumScale; - m_viewportConstraints.minimumScale = newMinimumScale; - } - - // If current scale factor was minimized, minimize new scale factor - if (m_pageDidRendered && isMinimized && m_viewportConstraints.userScalable) { -#if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) - setVisibleContentRect(m_visibleContentRect, newMinimumScale); -#else - m_viewImpl->page()->scalePage(newMinimumScale, m_visibleContentRect.location()); -#endif + && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits::epsilon()) + m_viewportConstraints.initialScale = minimumScale; + m_viewportConstraints.minimumScale = minimumScale; } #else m_viewImpl->informContentsSizeChange(size); #endif + if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1) + return; + + // FIXME: Do we really need to adjust visible content rect at here? + // if contents size is changed smaller and visible content rect is outside of content area, + // adjust visible content rect + bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect); + bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits::epsilon()); + if (needScrollAdjustment || needScaleAdjustment) { +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI(" setVisibleContentRect: [%d, %d], [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), scaleFactor()); +#endif + setVisibleContentRect(m_visibleContentRect, scaleFactor()); + } } void PageClientImpl::pageScaleFactorDidChange() @@ -640,9 +740,8 @@ void PageClientImpl::didCommitLoadForMainFrame(bool) { #if OS(TIZEN) m_pageDidRendered = false; -#if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT) - m_restoredScaleFactor = 0; -#endif + m_viewportFitsToContent = false; + m_nonemptyLayoutRendered = false; return; #endif notImplemented(); @@ -681,13 +780,15 @@ void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, Fin void PageClientImpl::updateTextInputState() { - InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext(); - if (inputMethodContext) - inputMethodContext->updateTextInputState(); - #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) m_textSelection->update(); + if (isTextSelectionMode() && isTextSelectionHandleDowned()) + return; #endif + + InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext(); + if (inputMethodContext) + inputMethodContext->updateTextInputState(); } void PageClientImpl::handleDownloadRequest(DownloadProxy* download) @@ -707,8 +808,15 @@ void PageClientImpl::pageDidRequestScroll(const IntPoint& point) #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) IntPoint newPoint = point; newPoint.scale(scaleFactor(), scaleFactor()); +#if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION) + if (!m_pageDidRendered) + m_scrollPositionBeforePageRendered = newPoint; + else + setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor()); +#else setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor()); #endif +#endif } #endif @@ -719,6 +827,9 @@ void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& poi m_restoredScrollPosition = point; m_restoredScrollPosition.scale(scale, scale); m_restoredScaleFactor = scale; +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor); +#endif // Before contents size is fixed, just update visible content rect's position m_visibleContentRect.setLocation(m_restoredScrollPosition); @@ -738,203 +849,6 @@ void PageClientImpl::textChangeInTextField(const String& name, const String& val } #endif -#if ENABLE(TIZEN_ISF_PORT) -void PageClientImpl::setInputMethodState(bool active, const String& type, const String& value) -{ - if (!active) { - InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext(); - if (inputMethodContext) - inputMethodContext->hideIMFContext(); - LOG(ISF, "- Keypad status : hide\n"); - return; - } - - Ewk_Settings* settings = ewk_view_settings_get(m_viewImpl->view()); - bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings); - -#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD) - if (m_clipboardHelper->isClipboardWindowOpened()) { - LOG(ISF, "[FAIL] Clipboard\n"); - return; - } -#endif - - LOG(ISF, "- Type (%s), Value (%s)\n", type.utf8().data(), value.utf8().data()); - -#if ENABLE(TIZEN_INPUT_TAG_EXTENSION) - if (type == "date") { - ewkViewInputPickerRequest(m_viewImpl->view(), EWK_INPUT_TYPE_DATE, value); - return; - } else if (type == "datetime") { - ewkViewInputPickerRequest(m_viewImpl->view(), EWK_INPUT_TYPE_DATETIME, value); - return; - } else if (type == "datetime-local") { - ewkViewInputPickerRequest(m_viewImpl->view(), EWK_INPUT_TYPE_DATETIMELOCAL, value); - return; - } else if (type == "month") { - ewkViewInputPickerRequest(m_viewImpl->view(), EWK_INPUT_TYPE_MONTH, value); - return; - } else if (type == "time") { - ewkViewInputPickerRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TIME, value); - return; - } else if (type == "week") { - ewkViewInputPickerRequest(m_viewImpl->view(), EWK_INPUT_TYPE_WEEK, value); - return; - } - -#if ENABLE(TIZEN_DATALIST_ELEMENT) - Vector optionList = m_viewImpl->page()->getFocusedInputElementDataList(); - if (optionList.size() > 0) { - if (type == "tel") - ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TELEPHONE, optionList); - else if (type == "number") - ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_NUMBER, optionList); - else if (type == "email") - ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_EMAIL, optionList); - else if (type == "url") - ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_URL, optionList); - else - ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TEXT, optionList); - - return; - } -#endif // ENABLE(TIZEN_DATALIST_ELEMENT) -#endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION) - - bool hasFocus = evas_object_focus_get(m_viewImpl->view()); - - if (!defaultKeypadEnabled) { - if (hasFocus) { - Eina_Rectangle dummyRectForCustomKeypadCallback; - memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle)); - evas_object_smart_callback_call(m_viewImpl->view(), "inputmethod,changed", &dummyRectForCustomKeypadCallback); - } - return; - } - - InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext(); - if (!inputMethodContext) - return; - - inputMethodContext->setType(type); - -#if ENABLE(TIZEN_SUPPORT_EMOJI) - if (type.isEmpty() && !value.isEmpty()) - inputMethodContext->setIMData(value); -#endif - - if (!hasFocus) - return; - - inputMethodContext->showIMFContext(); - - // input field zoom for external keyboard - ewk_view_focused_node_adjust(m_viewImpl->view(), EINA_TRUE); - - LOG(ISF, "- Keypad status : show\n"); -} -#else -void PageClientImpl::setInputMethodState(bool) { } -#endif // #if ENABLE(TIZEN_ISF_PORT) - -#if ENABLE(TIZEN_ISF_PORT) -void PageClientImpl::updateCursorOffset(int offset) -{ - InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext(); - if (!inputMethodContext) - return; - - inputMethodContext->setIMFContextCursorPosition(offset); -} - -void PageClientImpl::imContextCommitted(Ecore_IMF_Context* context, char* string) -{ - if (!m_viewImpl->page()->focusedFrame()) - return; - - m_viewImpl->page()->confirmComposition(String::fromUTF8(string)); -} - -void PageClientImpl::imContextPreeditChanged(Ecore_IMF_Context* context) -{ - if (!m_viewImpl->page()->focusedFrame()) - return; - - char* preeditStr = 0; - Eina_List* preeditAttrs = 0; - int cursorPosition = 0; - - ecore_imf_context_preedit_string_with_attributes_get(context, &preeditStr, &preeditAttrs, &cursorPosition); - if (!preeditStr) { - if (preeditAttrs) { - void* item = 0; - EINA_LIST_FREE(preeditAttrs, item) - free(item); - } - return; - } - - IntRect caretRect; - m_viewImpl->page()->getCaretPosition(caretRect); - caretRect.scale(scaleFactor()); - - int viewX, viewY; - evas_object_geometry_get(m_viewImpl->view(), &viewX, &viewY, 0, 0); - - int x = caretRect.x() - scrollPosition().x() + viewX; - int y = caretRect.y() - scrollPosition().y() + viewY; - int w = caretRect.width(); - int h = caretRect.height(); - ecore_imf_context_cursor_location_set(context, x, y, w, h); - - String preeditString = String::fromUTF8(preeditStr); - if (preeditStr) - free(preeditStr); - - Vector underlines; - -#if ENABLE(TIZEN_WEBKIT2_SUPPORT_JAPANESE_IME) - if (preeditAttrs) { - Eina_List* listIterator = 0; - void* item = 0; - EINA_LIST_FOREACH(preeditAttrs, listIterator, item) { - Ecore_IMF_Preedit_Attr* preeditAttr = static_cast(item); - - switch (preeditAttr->preedit_type) { - case ECORE_IMF_PREEDIT_TYPE_SUB1: - underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), false)); - break; - case ECORE_IMF_PREEDIT_TYPE_SUB2: - case ECORE_IMF_PREEDIT_TYPE_SUB3: - underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(255, 255, 255), false)); - break; - case ECORE_IMF_PREEDIT_TYPE_SUB4: - underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(46, 168, 255), false)); - break; - case ECORE_IMF_PREEDIT_TYPE_SUB5: - underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 98, 195), false)); - break; - case ECORE_IMF_PREEDIT_TYPE_SUB6: - underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(118, 222, 55), false)); - break; - case ECORE_IMF_PREEDIT_TYPE_SUB7: - underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 153, 153), false)); - break; - } - } - EINA_LIST_FREE(preeditAttrs, item) - free(item); - - } else - underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false)); -#else - underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false)); -#endif - - m_viewImpl->page()->setComposition(preeditString, underlines, cursorPosition); -} -#endif // #if ENABLE(TIZEN_ISF_PORT) - void PageClientImpl::updateFormNavigation(int length, int offset) { notImplemented(); @@ -983,6 +897,7 @@ void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScal #endif m_scaleFactor = adjustScaleWithViewport(newScale); + m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits::epsilon(); m_visibleContentRect.setLocation(newRect.location()); m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor); @@ -1008,7 +923,7 @@ void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScal ceilf(m_visibleContentRect.height() / m_scaleFactor)); if (!drawingArea()) return; - drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_viewImpl->scrollPosition())); + drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition())); #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE) // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect. drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect); @@ -1016,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 @@ -1111,6 +1026,10 @@ void PageClientImpl::resumeContent() if (!m_hasSuspendedContent) return; +#if ENABLE(TIZEN_DLOG_SUPPORT) + TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_viewImpl->scrollPosition().x(), m_viewImpl->scrollPosition().y(), m_viewImpl->scaleFactor()); +#endif + // FIXME: Update visibleContentRect with m_viewImpl after resuming content. // The concept is that the values of EwkViewImpl and PageClient can be different // during suspending content and they become same when content is resumed. @@ -1222,22 +1141,22 @@ 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(); - if (inputMethodContext && !inputMethodContext->isShow()) + if (inputMethodContext) inputMethodContext->hideIMFContext(); 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) @@ -1267,12 +1186,20 @@ void PageClientImpl::textSelectonHandleUp() } #endif -#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu() { m_textSelection->requestToShow(); } -#endif + +void PageClientImpl::initTextSelectionHandlesMouseDownedStatus() +{ + m_textSelection->initHandlesMouseDownedStatus(); +} + +void PageClientImpl::changeContextMenuPosition(IntPoint& point) +{ + m_textSelection->changeContextMenuPosition(point); +} #endif #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE) @@ -1318,9 +1245,9 @@ bool PageClientImpl::isClipboardWindowOpened() return m_clipboardHelper->isClipboardWindowOpened(); } -void PageClientImpl::clearClipboardSelectionHandler() +void PageClientImpl::closeClipboardWindow() { - m_clipboardHelper->clearClipboardSelectionHandler(); + m_clipboardHelper->closeClipboardWindow(); } #endif @@ -1383,7 +1310,7 @@ void PageClientImpl::startDrag(const DragData& dragData, PassRefPtrpage()->dragEntered(dragInfo, dragStorageName); setDragMode(true); - m_drag->setDragData(dragInfo); + m_drag->setDragData(dragInfo, dragImage); m_drag->Show(); } #endif @@ -1487,6 +1414,13 @@ void PageClientImpl::didRenderFrame() m_pageDidRendered = true; initializeVisibleContentRect(); } + +#if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION) + if (m_waitFrameOfNewViewortSize) { + m_waitFrameOfNewViewortSize = false; + ewkViewRotatePrepared(m_viewImpl->view()); + } +#endif } #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION) @@ -1521,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); @@ -1601,10 +1494,16 @@ PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl) PageClientEvasGL::~PageClientEvasGL() { - m_viewImpl->page()->close(); + if (m_viewImpl && m_viewImpl->page()) + m_viewImpl->page()->close(); +} + +void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle) +{ + PageClientImpl::updateViewportSize(viewportSize, angle); } -void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize) +void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size) { if (m_surface) { evas_gl_surface_destroy(m_evasGL, m_surface); @@ -1612,14 +1511,15 @@ void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize) } setTargetSurface(); - PageClientImpl::updateViewportSize(viewportSize); + PageClientImpl::updateVisibleContentRectSize(size); } void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect) { -#if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING) - drawContents(); +#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING) + if (!isDirectRendering()) #endif + drawContents(); m_viewImpl->redrawRegion(rect); #if ENABLE(TIZEN_SCREEN_READER) @@ -1633,10 +1533,11 @@ void PageClientEvasGL::displayViewport() #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING) // We should not draw here when Direct Rendering is enabled. // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing(). - ewk_view_mark_for_sync(m_viewImpl->view()); -#else - setViewNeedsDisplay(IntRect(IntPoint(), viewSize())); + if (isDirectRendering()) + ewk_view_mark_for_sync(m_viewImpl->view()); + else #endif + setViewNeedsDisplay(IntRect(IntPoint(), viewSize())); #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR) updateScrollbar(); @@ -1649,7 +1550,14 @@ void PageClientEvasGL::displayViewport() void PageClientEvasGL::drawContents() { - if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE) + if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()) || !m_isVisible) + return; + + WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer(); + if (!renderer) + return; + + if (!makeContextCurrent()) return; WebCore::TransformationMatrix matrix; @@ -1657,50 +1565,48 @@ void PageClientEvasGL::drawContents() IntSize ewkViewSize = viewSize(); #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING) - Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view())); - m_angle = ecore_evas_rotation_get(ee); - if (drawingArea()) - drawingArea()->setAngle(m_angle); - matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle); - - if (m_angle == 90 || m_angle == 270) { - glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width()); - if (m_angle == 90) - matrix.translate(-ewkViewSize.width(), 0); - else if (m_angle == 270) - matrix.translate(0, -ewkViewSize.height()); - clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize()); - } else { + if (isDirectRendering()) { + Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view())); + m_angle = ecore_evas_rotation_get(ee); + renderer->setAngle(m_angle); + matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle); + + if (m_angle == 90 || m_angle == 270) { + glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width()); + if (m_angle == 90) + matrix.translate(-ewkViewSize.width(), 0); + else if (m_angle == 270) + matrix.translate(0, -ewkViewSize.height()); + clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize()); + } else { + glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height()); + if (m_angle == 180) + matrix.translate(-ewkViewSize.width(), -ewkViewSize.height()); + clipRect = IntRect(IntPoint(), ewkViewSize); + } + } else +#endif + { glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height()); - if (m_angle == 180) - matrix.translate(-ewkViewSize.width(), -ewkViewSize.height()); clipRect = IntRect(IntPoint(), ewkViewSize); } -#else - glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height()); - clipRect = IntRect(IntPoint(), ewkViewSize); -#endif + matrix *= m_viewImpl->transformToView().toTransformationMatrix(); - if (drawingArea()) { - if (drawingArea()->layerTreeCoordinatorProxy()) { - WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer(); #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE) - if (m_shouldMakeBackupTexture) { - glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height()); - glClearColor(1, 1, 1, 1); - glClear(GL_COLOR_BUFFER_BIT); - renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor); - m_shouldMakeBackupTexture = false; - } else if (m_shouldShowBackupTexture) { - matrix.makeIdentity(); - glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height()); - renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect); - } else -#endif - renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor); - } - } + if (m_shouldMakeBackupTexture) { + glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height()); + glClearColor(1, 1, 1, 1); + glClear(GL_COLOR_BUFFER_BIT); + renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor); + m_shouldMakeBackupTexture = false; + } else if (m_shouldShowBackupTexture) { + matrix.makeIdentity(); + glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height()); + renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect); + } else +#endif + renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor); } void PageClientEvasGL::didRenderFrame() @@ -1720,8 +1626,11 @@ void PageClientEvasGL::initializeAcceleratedCompositingMode() m_config = evas_gl_config_new(); #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING) - setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1); - m_config->options_bits = EVAS_GL_OPTIONS_DIRECT; + char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING"); + if (!directRenderingEnv || atoi(directRenderingEnv)) { + setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1); + m_config->options_bits = EVAS_GL_OPTIONS_DIRECT; + } #endif m_config->color_format = EVAS_GL_RGBA_8888; m_config->depth_bits = EVAS_GL_DEPTH_BIT_24; @@ -1814,15 +1723,18 @@ void PageClientEvasGL::setTargetSurface() } #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING) - makeContextCurrent(); -#else - if (makeContextCurrent()) { - glViewport(0, 0, width, height); - glClearColor(1.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glFinish(); - } + if (isDirectRendering()) + makeContextCurrent(); + else #endif + { + if (makeContextCurrent()) { + glViewport(0, 0, width, height); + glClearColor(1.0, 1.0, 1.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + glFinish(); + } + } Evas_Native_Surface nativeSurface; if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))