[Title] Implemented selection by doubleTap in WebKit.
[Issue#] N/A
[Problem] When doubleTap on any text of email composor, sometimes selection is not working properly.
[Cause] Current, selection by doubleTap is implemented in Email.
So, when doubleTap on any text of email composor,
selection routine from email is called and tap is performed twice from WebKit.
Tap should not be performed in case of doubleTap from email.
[Solution] Moved selection by doubleTap to WebKit.
Change-Id: I4440325118c302b2473a9b1f23734cf060f71eb3
double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
m_viewportConstraints = computeViewportConstraints(attributes);
+#if ENABLE(TIZEN_GESTURE)
+ bool doubleTapEnabled = userScalable();
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ doubleTapEnabled |= ewk_settings_select_word_automatically_get(ewk_view_settings_get(m_viewImpl->view()));
+#endif
+ m_viewImpl->setDoubleTapEnabled(doubleTapEnabled);
+#endif
+
// Initially, m_scaleFactor is not decided yet.
// So, we should update visible content rect at here.
if (!m_scaleFactor) {
{
m_textSelection->changeContextMenuPosition(point);
}
+
+void PageClientImpl::selectWordAutomatically(const IntPoint& point)
+{
+ m_textSelection->selectWordAutomatically(point);
+}
#endif
#if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
void requestToShowTextSelectionHandlesAndContextMenu();
void initTextSelectionHandlesMouseDownedStatus();
void changeContextMenuPosition(WebCore::IntPoint& point);
+ void selectWordAutomatically(const WebCore::IntPoint& point);
#endif
#if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
return false;
#endif
}
+
+Eina_Bool ewk_settings_select_word_automatically_set(Ewk_Settings* settings, Eina_Bool enable)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ settings->setAutoSelectWord(enable);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Eina_Bool ewk_settings_select_word_automatically_get(const Ewk_Settings* settings)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ return settings->autoSelectWord();
+#else
+ return false;
+#endif
+}
EAPI Eina_Bool ewk_settings_text_style_state_enabled_get(const Ewk_Settings *settings);
// #endif
+// #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+/**
+ * Requests to enable/disable to select word by double tap
+ *
+ * @param settings settings object to enable/disable to select word by double tap
+ * @param enable @c EINA_TRUE to select word by double tap
+ * @c EINA_FALSE to disable
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_settings_select_word_automatically_set(Ewk_Settings *settings, Eina_Bool enabled);
+
+/**
+ * Returns enable/disable text selection by double tap
+ *
+ * @param settings settings object to get whether word by double tap is selected
+ *
+ * @return @c EINA_TRUE on enable or @c EINA_FALSE on disable
+ */
+EAPI Eina_Bool ewk_settings_select_word_automatically_get(const Ewk_Settings *settings);
+// #endif
+
#ifdef __cplusplus
}
#endif
void setTextSelectionEnabled(bool enable) { m_textSelectionEnabled = enable; }
bool autoClearTextSelection() const { return m_autoClearTextSelection; }
void setAutoClearTextSelection(bool enable) { m_autoClearTextSelection = enable; }
+ bool autoSelectWord() const { return m_autoSelectWord; }
+ void setAutoSelectWord(bool enable) { m_autoSelectWord = enable; }
#endif
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
, m_textSelectionEnabled(true)
, m_autoClearTextSelection(true)
+ , m_autoSelectWord(false)
#endif
#endif
{
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
bool m_textSelectionEnabled;
bool m_autoClearTextSelection;
+ bool m_autoSelectWord;
#endif
#endif
};
void GestureClient::endDoubleTap(const IntPoint& position)
{
+ if (!m_isGestureEnabled) {
+ setDoubleTapScheduled(true, position);
+ return;
+ }
+
PageClientImpl* pageClientImpl = ewkViewGetPageClient(m_viewImpl->view());
-#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
- if (!pageClientImpl || m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ if (ewk_settings_select_word_automatically_get(ewk_view_settings_get(m_viewImpl->view()))) {
+ pageClientImpl->selectWordAutomatically(position);
return;
+ }
#endif
- if (!m_isTapEnabled) {
- setDoubleTapScheduled(true, position);
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+ if (!pageClientImpl || m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
return;
- }
+#endif
if (pageClientImpl->userScalable())
m_smartZoom->start(position.x(), position.y());
#endif
, m_handleMovingDirection(HandleMovingDirectionNormal)
, m_isSelectionInScrollingMode(false)
+ , m_isAutoWordSelectionScheduled(false)
{
ASSERT(viewWidget);
informTextStyleState();
#endif
+ if (!editorState.shouldIgnoreCompositionSelectionChange && !editorState.hasComposition && m_isAutoWordSelectionScheduled)
+ setAutoWordSelection(m_scheduledAutoWordSelectionPosition);
+
if (isTextSelectionMode()) {
if (!editorState.selectionIsRange) {
if (editorState.isContentEditable && !evas_object_focus_get(m_viewImpl->view())) {
setIsTextSelectionMode(false);
IntPoint contentsPoint = m_viewImpl->transformFromScene().mapPoint(point);
- bool result = m_viewImpl->page()->selectClosestWord(contentsPoint);
+ bool result = m_viewImpl->page()->selectClosestWord(contentsPoint, false);
if (!result)
return false;
if (!scrolledX && !scrolledY) {
viewPoint = m_viewImpl->transformFromScene().mapPoint(updatedPoint);
- m_viewImpl->page()->selectClosestWord(viewPoint);
+ m_viewImpl->page()->selectClosestWord(viewPoint, false);
updateMagnifier(updatedPoint);
}
} else {
viewPoint = m_viewImpl->transformFromScene().mapPoint(point);
- m_viewImpl->page()->selectClosestWord(viewPoint);
+ m_viewImpl->page()->selectClosestWord(viewPoint, false);
updateMagnifier(point);
}
showMagnifier();
ewkViewTextStyleState(m_viewImpl->view(), startEvasPoint, endEvasPoint);
}
#endif
+
+void TextSelection::selectWordAutomatically(const IntPoint& point)
+{
+ EditorState editorState = m_viewImpl->page()->editorState();
+ if (editorState.hasComposition) {
+ setAutoWordSelectionScheduled(true, point);
+ m_viewImpl->inputMethodContext()->resetIMFContext();
+ return;
+ }
+
+ setAutoWordSelection(point);
+}
+
+void TextSelection::setAutoWordSelectionScheduled(bool scheduled, const IntPoint& position)
+{
+ m_isAutoWordSelectionScheduled = scheduled;
+ m_scheduledAutoWordSelectionPosition = position;
+}
+
+void TextSelection::setAutoWordSelection(const IntPoint& point)
+{
+ IntPoint contentsPoint = m_viewImpl->transformFromScene().mapPoint(point);
+
+ setAutoWordSelectionScheduled(false, IntPoint(0, 0));
+ setIsTextSelectionMode(false);
+
+ bool result = m_viewImpl->page()->selectClosestWord(contentsPoint, true);
+ if (!result)
+ return;
+
+ setIsTextSelectionMode(true);
+
+ updateHandlers();
+ showContextMenu();
+}
} // namespace WebKit
#endif // TIZEN_WEBKIT2_TEXT_SELECTION
void initHandlesMouseDownedStatus();
void changeContextMenuPosition(WebCore::IntPoint& position);
+ void selectWordAutomatically(const WebCore::IntPoint& point);
friend class PageClientImpl; // to allow hideHandlers() call while zooming
private:
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
void informTextStyleState();
#endif
+ void setAutoWordSelectionScheduled(bool scheduled, const WebCore::IntPoint& position);
+ void setAutoWordSelection(const WebCore::IntPoint& point);
private:
EwkViewImpl* m_viewImpl;
#endif
int m_handleMovingDirection;
bool m_isSelectionInScrollingMode;
+ bool m_isAutoWordSelectionScheduled;
+ WebCore::IntPoint m_scheduledAutoWordSelectionPosition;
};
} // namespace WebKit
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- bool selectClosestWord(const WebCore::IntPoint&);
+ bool selectClosestWord(const WebCore::IntPoint&, bool isAutoWordSelection);
int setLeftSelection(const WebCore::IntPoint&, const int direction);
int setRightSelection(const WebCore::IntPoint&, const int direction);
bool getSelectionHandlers(WebCore::IntRect& leftRect, WebCore::IntRect& rightRect, int& selectionDirection);
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-bool WebPageProxy::selectClosestWord(const IntPoint& point)
+bool WebPageProxy::selectClosestWord(const IntPoint& point, bool isAutoWordSelection)
{
if (!isValid())
return false;
bool result = false;
- process()->sendSync(Messages::WebPage::SelectClosestWord(point), Messages::WebPage::SelectClosestWord::Reply(result), m_pageID);
+ process()->sendSync(Messages::WebPage::SelectClosestWord(point, isAutoWordSelection), Messages::WebPage::SelectClosestWord::Reply(result), m_pageID);
return result;
}
HandleMovingDirectionNormal,
HandleMovingDirectionReverse,
};
- void selectClosestWord(const WebCore::IntPoint&, bool& result);
+ void selectClosestWord(const WebCore::IntPoint&, bool isAutoWordSelection, bool& result);
void setLeftSelection(const WebCore::IntPoint&, const int direction, int& result);
void setRightSelection(const WebCore::IntPoint&, const int direction, int& result);
bool isSelectionOnlyImage() const;
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- SelectClosestWord(WebCore::IntPoint point) -> (bool result)
+ SelectClosestWord(WebCore::IntPoint point, bool isAutoWordSelection) -> (bool result)
SetLeftSelection(WebCore::IntPoint point, int direction) -> (int result)
SetRightSelection(WebCore::IntPoint point, int direction) -> (int result)
GetSelectionHandlers() -> (WebCore::IntRect leftRect, WebCore::IntRect rightRect, int selectionDirection, WebCore::IntRect updateEditorRect)
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-void WebPage::selectClosestWord(const IntPoint& point, bool& result)
+void WebPage::selectClosestWord(const IntPoint& point, bool isAutoWordSelection, bool& result)
{
result = false;
HTMLInputElement* inputElement = node->toInputElement();
if (hitTestResult.isContentEditable()) {
+#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+ if (!inputElement || (inputElement
+ && !inputElement->isDateField() && !inputElement->isDateTimeField() && !inputElement->isDateTimeLocalField()
+ && !inputElement->isMonthField() && !inputElement->isTimeField() && !inputElement->isWeekField())) {
+ result = setCaretPosition(point);
+ if (!isAutoWordSelection)
+ return;
+ }
+#else
result = setCaretPosition(point);
- return;
+ if (!isAutoWordSelection)
+ return;
+#endif
}
#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)