Do not select range when picker input element has focus in focus ui mode
authorSangYong Park <sy302.park@samsung.com>
Tue, 17 Sep 2013 00:40:57 +0000 (09:40 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 17 Sep 2013 03:42:12 +0000 (03:42 +0000)
[Title] Do not select range when picker input element has focus in focus ui mode
[Issue#] N_SE-52290
[Problem] Picker input element was selected in focus ui mode
[Cause] Input element's default handler did select text
[Solution] Do not select range when picker input element has focus in focus ui mode

Change-Id: Id4ef6876bfba9a46f384cd1b5aed019c25022a06

Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/page/FocusController.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp

index fd32fea..02f0092 100755 (executable)
 #include "TouchEvent.h"
 #endif
 
+#if ENABLE(TIZEN_FOCUS_UI) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+#include "Settings.h"
+#include "WindowsKeyboardCodes.h"
+#include "htmlediting.h"
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -354,6 +360,11 @@ bool HTMLInputElement::isTextFormControlMouseFocusable() const
 
 void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection)
 {
+#if ENABLE(TIZEN_FOCUS_UI) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+    if (shouldUsePicker() && document()->settings() && document()->settings()->isSpatialNavigationEnabled())
+        return;
+#endif
+
     if (isTextField()) {
         if (!restorePreviousSelection || !hasCachedSelection())
             select();
@@ -1065,6 +1076,14 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
         m_inputType->handleKeydownEvent(static_cast<KeyboardEvent*>(evt));
         if (evt->defaultHandled())
             return;
+#if ENABLE(TIZEN_FOCUS_UI) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+        if (static_cast<KeyboardEvent*>(evt)->keyCode() == VK_RETURN && shouldUsePicker()
+            && document()->settings() && document()->settings()->isSpatialNavigationEnabled()) {
+            setSelectionRange(0, 0);
+            evt->setDefaultHandled();
+            return;
+        }
+#endif
     }
 
     // Call the base event handler before any of our own event handling for almost all events in text fields.
@@ -1777,4 +1796,11 @@ void ListAttributeTargetObserver::idTargetChanged()
 }
 #endif
 
+#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+bool HTMLInputElement::shouldUsePicker()
+{
+    return (isDateField() || isDateTimeField() || isDateTimeLocalField() || isMonthField() || isTimeField() || isWeekField());
+}
+#endif
+
 } // namespace
index d2128b6..19c92cf 100755 (executable)
@@ -271,6 +271,10 @@ public:
 
     virtual const AtomicString& name() const OVERRIDE;
 
+#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+    bool shouldUsePicker();
+#endif
+
 protected:
     HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
     void createShadowSubtree();
index d3ff2a6..3379564 100755 (executable)
@@ -195,7 +195,15 @@ static inline int adjustedTabIndex(Node* node, KeyboardEvent* event)
 static inline bool shouldVisit(Node* node, KeyboardEvent* event)
 {
     ASSERT(node);
+#if ENABLE(TIZEN_FOCUS_UI) && ENABLE(FULLSCREEN_API)
+    if (!node->isKeyboardFocusable(event) && !isNonFocusableShadowHost(node, event))
+        return false;
+
+    Element* fullscreenElement = node->document()->webkitIsFullScreen() ? node->document()->webkitFullscreenElement() : 0;
+    return (!fullscreenElement || fullscreenElement->contains(node));
+#else
     return node->isKeyboardFocusable(event) || isNonFocusableShadowHost(node, event);
+#endif
 }
 
 FocusController::FocusController(Page* page)
@@ -899,6 +907,10 @@ void FocusController::findFocusCandidateInContainer(Node* container, const Layou
     current.focusableNode = focusedNode;
     current.visibleNode = focusedNode;
 
+#if ENABLE(TIZEN_FOCUS_UI) && ENABLE(FULLSCREEN_API)
+    Element* fullscreenElement = node->document()->webkitIsFullScreen() ? node->document()->webkitFullscreenElement() : 0;
+#endif
+
     for (; node; node = (node->isFrameOwnerElement() || canScrollInDirection(node, direction)) ? node->traverseNextSibling(container) : node->traverseNextNode(container)) {
         if (node == focusedNode)
             continue;
@@ -913,6 +925,11 @@ void FocusController::findFocusCandidateInContainer(Node* container, const Layou
 #endif
             continue;
 
+#if ENABLE(TIZEN_FOCUS_UI) && ENABLE(FULLSCREEN_API)
+        if (fullscreenElement && !fullscreenElement->contains(node))
+            continue;
+#endif
+
         FocusCandidate candidate = FocusCandidate(node, direction);
         if (candidate.isNull())
             continue;
index 458fc83..1891e99 100755 (executable)
@@ -4250,10 +4250,8 @@ void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEv
         else if (impl->pageProxy->isViewVisible()) {
             IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
             WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
-            if (hitTestResultData.isContentEditable && impl->inputMethodContext()) {
-                evas_object_focus_set(ewkView, true);
-                impl->inputMethodContext()->updateTextInputState();
-            }
+            if (hitTestResultData.isContentEditable && impl->inputMethodContext())
+                impl->inputMethodContext()->updateTextInputStateByUserAction(true);
         }
 #endif
     }
index 1071611..0cbda23 100755 (executable)
@@ -648,7 +648,7 @@ void InputMethodContextEfl::resetIMFContext()
 void InputMethodContextEfl::showIMFContext(const EditorState& editor, bool isUserAction)
 {
     Ewk_Settings* settings = ewk_view_settings_get(m_viewImpl->view());
-    bool isContextTransition = (m_context ? m_contextID != editor.inputMethodContextID : m_state != ECORE_IMF_INPUT_PANEL_STATE_HIDE);
+    bool isContextTransition = (m_contextID && m_contextID != editor.inputMethodContextID);
 
     if (!isUserAction && !isContextTransition) {
         if (!ewk_settings_uses_keypad_without_user_action_get(settings) || (m_focused && m_contextID == editor.inputMethodContextID))