From 93636ed9f10b7ce4ae4a4c5e2771aa6d42d0057a Mon Sep 17 00:00:00 2001 From: Yuni Jeong Date: Tue, 26 Mar 2013 19:12:05 +0900 Subject: [PATCH] Fixed text selection is cleared when user try to scroll in editable content. [Title] Fixed text selection is cleared when user try to scroll in editable content. [Issue#] P130301-2648 [Problem] text selection is cleared when user try to scroll in editable content. [Cause] There is routine to clear text selection when user try to scroll in editable content. [Solution] Removed routine to clear text selection when user try to scroll in editable content. Added routine to update text selection when scrolling is performed by javascript. Change-Id: I233a187a4cf1a257bd981e7bb33b0db9c1f2302b --- Source/WebCore/page/ContextMenuController.cpp | 2 + Source/WebKit2/Shared/EditorState.cpp | 4 ++ Source/WebKit2/Shared/EditorState.h | 4 ++ .../WebKit2/UIProcess/API/efl/PageClientImpl.cpp | 7 +++ Source/WebKit2/UIProcess/API/efl/PageClientImpl.h | 1 + Source/WebKit2/UIProcess/API/efl/ewk_view.cpp | 11 ++++ .../UIProcess/API/efl/tizen/TextSelection.cpp | 58 +++++++++++++++++----- .../UIProcess/API/efl/tizen/TextSelection.h | 8 +++ .../WebProcess/WebCoreSupport/WebEditorClient.cpp | 3 ++ Source/WebKit2/WebProcess/WebPage/WebPage.h | 11 ++++ .../WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp | 8 +++ 11 files changed, 104 insertions(+), 13 deletions(-) diff --git a/Source/WebCore/page/ContextMenuController.cpp b/Source/WebCore/page/ContextMenuController.cpp index 92ae602..5159d1b 100755 --- a/Source/WebCore/page/ContextMenuController.cpp +++ b/Source/WebCore/page/ContextMenuController.cpp @@ -960,6 +960,7 @@ void ContextMenuController::populate() appendItem(StopItem, m_contextMenu.get()); appendItem(ReloadItem, m_contextMenu.get()); #else +#if !ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2) if (frame->page() && frame->page()->backForward()->canGoBackOrForward(-1)) appendItem(BackItem, m_contextMenu.get()); @@ -973,6 +974,7 @@ void ContextMenuController::populate() else appendItem(ReloadItem, m_contextMenu.get()); #endif +#endif #if ENABLE(INSPECTOR) } #endif diff --git a/Source/WebKit2/Shared/EditorState.cpp b/Source/WebKit2/Shared/EditorState.cpp index 399c223..b07e4d1 100644 --- a/Source/WebKit2/Shared/EditorState.cpp +++ b/Source/WebKit2/Shared/EditorState.cpp @@ -47,6 +47,7 @@ void EditorState::encode(CoreIPC::ArgumentEncoder* encoder) const #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) encoder->encode(editorRect); + encoder->encode(updateEditorRectOnly); #endif #if PLATFORM(QT) @@ -92,6 +93,9 @@ bool EditorState::decode(CoreIPC::ArgumentDecoder* decoder, EditorState& result) #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) if (!decoder->decode(result.editorRect)) return false; + + if (!decoder->decode(result.updateEditorRectOnly)) + return false; #endif #if PLATFORM(QT) diff --git a/Source/WebKit2/Shared/EditorState.h b/Source/WebKit2/Shared/EditorState.h index 48a341f..ab59782 100644 --- a/Source/WebKit2/Shared/EditorState.h +++ b/Source/WebKit2/Shared/EditorState.h @@ -45,6 +45,9 @@ struct EditorState { #if ENABLE(TIZEN_ISF_PORT) , inputMethodHints(0) #endif +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) + , updateEditorRectOnly(false) +#endif #if PLATFORM(QT) , cursorPosition(0) , anchorPosition(0) @@ -66,6 +69,7 @@ struct EditorState { #endif #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) WebCore::IntRect editorRect; + bool updateEditorRectOnly; #endif #if PLATFORM(QT) // The anchor, cursor represent either the selection or composition, depending diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 519bcdc..94e2890 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -1299,6 +1299,13 @@ void PageClientImpl::textSelectonHandleUp() m_textSelection->textSelectionHandleUp(); } #endif + +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) +void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu() +{ + m_textSelection->requestToShow(); +} +#endif #endif #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE) diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index d17e6bb..b1ec5bd 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -187,6 +187,7 @@ public: void textSelectonHandleMove(const WebCore::IntPoint& point); void textSelectonHandleUp(); #endif + void requestToShowTextSelectionHandlesAndContextMenu(); #endif #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index 25686f7..88e7d01 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -5115,6 +5115,17 @@ void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEv if (priv->areMouseEventsEnabled) return; +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) + if (wasHandled && priv->pageClient->isTextSelectionMode()) { + if (type == WebEvent::TouchStart) + priv->pageClient->updateTextSelectionHandlesAndContextMenu(false); + else if (type == WebEvent::TouchMove) + priv->pageClient->updateTextSelectionHandlesAndContextMenu(false); + else if (type == WebEvent::TouchEnd) + priv->pageClient->requestToShowTextSelectionHandlesAndContextMenu(); + } +#endif + // We have to check TouchStart, TouchMove and TouchEnd with handled. // The Pan and Flick will be enabled if Touch Start was not handled, // and Touch Move was not handled or did not occur. diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp index 2b542c8..a653683 100644 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp @@ -44,6 +44,7 @@ TextSelection::TextSelection(Evas_Object* viewWidget, WebPageProxy* page, PageCl , m_isTextSelectionDowned(false) , m_isTextSelectionMode(false) , m_moveAnimator(0) + , m_showTimer(0) { ASSERT(viewWidget); @@ -85,8 +86,11 @@ TextSelection::~TextSelection() void TextSelection::update() { - if (isTextSelectionMode() ) { - EditorState editorState = m_page->editorState(); + EditorState editorState = m_page->editorState(); + if (editorState.updateEditorRectOnly) + return; + + if (isTextSelectionMode()) { if (!editorState.selectionIsRange) { if (editorState.isContentEditable && !evas_object_focus_get(m_object)) { WebCore::IntRect caretRect; @@ -116,7 +120,6 @@ void TextSelection::update() } #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION) else { - EditorState editorState = m_page->editorState(); if (editorState.isContentEditable && !editorState.selectionIsRange) { WebCore::IntRect caretRect; m_page->getCaretPosition(caretRect); @@ -160,10 +163,11 @@ void TextSelection::hide() void TextSelection::updateHandlers() { WebCore::IntRect leftRect, rightRect; - if (!m_page->getSelectionHandlers(leftRect, rightRect)) { - clear(); + if (!m_page->getSelectionHandlers(leftRect, rightRect)) return; - } + + m_lastLeftHandleRect = leftRect; + m_lastRightHandleRect = rightRect; AffineTransform toEvasTransform = m_viewImpl->transformToScene(); WebCore::IntPoint leftEvasPoint = toEvasTransform.mapPoint(leftRect.minXMaxYCorner()); @@ -237,10 +241,9 @@ void TextSelection::showContextMenu() #endif if (editorState.selectionIsRange) { WebCore::IntRect leftRect, rightRect; - if (!m_page->getSelectionHandlers(leftRect, rightRect)) { - clear(); + if (!m_page->getSelectionHandlers(leftRect, rightRect)) return; - } + #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) // Checking if this point is in viewport area. If the calcualated // point/Left/Right point are in view port then draw else do not draw the @@ -543,10 +546,6 @@ void TextSelection::textSelectionHandleDown(const IntPoint& position) if (selectedHandle->isMouseDowned()) return; } - - EditorState editorState = m_page->editorState(); - if (editorState.isContentEditable) - setIsTextSelectionMode(false); } void TextSelection::textSelectionHandleMove(const IntPoint& position) @@ -576,6 +575,39 @@ bool TextSelection::isAutomaticClearEnabled() return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(m_object)); } +void TextSelection::requestToShow() +{ + if (m_showTimer) + ecore_timer_del(m_showTimer); + m_showTimer = ecore_timer_loop_add((double)200.0/1000.0, showTimerCallback, this); +} + +Eina_Bool TextSelection::showTimerCallback(void* data) +{ + TextSelection* textSelection = static_cast(data); + textSelection->showHandlesAndContextMenu(); + + return ECORE_CALLBACK_RENEW; +} + +void TextSelection::showHandlesAndContextMenu() +{ + WebCore::IntRect leftRect, rightRect; + if (m_page->getSelectionHandlers(leftRect, rightRect)) { + if ((leftRect == m_lastLeftHandleRect) && (rightRect == m_lastRightHandleRect)) { + if (m_showTimer) { + ecore_timer_del(m_showTimer); + m_showTimer = 0; + } + + updateHandlesAndContextMenu(true); + } + + m_lastLeftHandleRect = leftRect; + m_lastRightHandleRect = rightRect; + } +} + } // namespace WebKit #endif // TIZEN_WEBKIT2_TEXT_SELECTION diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h index c7f3e6b..ca3a706 100644 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h @@ -80,6 +80,8 @@ public: void textSelectionHandleUp(); #endif + void requestToShow(); + friend class PageClientImpl; // to allow hideHandlers() call while zooming private: TextSelection(Evas_Object*, WebPageProxy*, PageClientImpl*); @@ -105,6 +107,9 @@ private: TextSelectionHandle* getSelectedHandle(const WebCore::IntPoint& position); #endif + static Eina_Bool showTimerCallback(void* data); + void showHandlesAndContextMenu(); + private: Evas_Object* m_object; EwkViewImpl* m_viewImpl; @@ -116,6 +121,9 @@ private: bool m_isTextSelectionDowned; bool m_isTextSelectionMode; Ecore_Animator* m_moveAnimator; + Ecore_Timer* m_showTimer; + WebCore::IntRect m_lastLeftHandleRect; + WebCore::IntRect m_lastRightHandleRect; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp index c878e9b..47a1d0e 100755 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp @@ -191,6 +191,9 @@ void WebEditorClient::respondToChangedSelection(Frame* frame) return; EditorState state = m_page->editorState(); +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) + m_page->setEditorState(state); +#endif m_page->send(Messages::WebPageProxy::EditorStateChanged(state)); diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 3e5f4fd..7329927 100755 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -117,6 +117,10 @@ OBJC_CLASS WKAccessibilityWebPageObject; #include "ScreenReader.h" #endif +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) +#include "EditorState.h" +#endif + namespace CoreIPC { class ArgumentDecoder; class Connection; @@ -398,6 +402,9 @@ public: PassRefPtr createPlugin(WebFrame*, WebCore::HTMLPlugInElement*, const Plugin::Parameters&); EditorState editorState() const; +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) + void setEditorState(const EditorState& editorState) { m_editorState = editorState;} +#endif String renderTreeExternalRepresentation() const; uint64_t renderTreeSize() const; @@ -1140,6 +1147,10 @@ private: #if ENABLE(TIZEN_ISF_PORT) bool m_isSettingComposition; #endif + +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) + EditorState m_editorState; +#endif }; #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT) diff --git a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp index 9254da9..68437f5 100755 --- a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp @@ -1390,6 +1390,14 @@ void WebPage::getSelectionHandlers(IntRect& leftRect, IntRect& rightRect) if (selectionRoot) { WebCore::IntRect editorRect = focusedFrame->view()->contentsToWindow(selectionRoot->getPixelSnappedRect()); +#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) + if (m_editorState.editorRect != editorRect) { + EditorState state = editorState(); + state.updateEditorRectOnly = true; + send(Messages::WebPageProxy::EditorStateChanged(state)); + } +#endif + if (leftRect.maxY() > editorRect.maxY()) { leftRect.setY(editorRect.y()); leftRect.setHeight(editorRect.height()); -- 2.7.4