Changeset 171182 in webkit


Ignore:
Timestamp:
Jul 17, 2014 3:55:57 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Add a "focus,notfound" signal.
https://bugs.webkit.org/show_bug.cgi?id=134674

Patch by Sanghyup Lee <sh53.lee@samsung.com> on 2014-07-17
Reviewed by Gyuyoung Kim.

Add a "focus,notfound" signal to handover focus control to application
because there are no elements of webview to focus on the given direction.

Application can decide to move the focus to next widget of ewk_view or something else
by using this signal.

  • UIProcess/API/efl/EwkViewCallbacks.h:
  • UIProcess/API/efl/ewk_view.h:
  • UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp: Added keyDown and keyUp function.

(EWK2UnitTest::EWK2UnitTestBase::waitUntilDirectionChanged):
(EWK2UnitTest::EWK2UnitTestBase::keyDown):
(EWK2UnitTest::EWK2UnitTestBase::keyUp):

  • UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
  • UIProcess/API/efl/tests/test_ewk2_view.cpp:

(EWK2ViewTest::FocusNotFoundCallback):
(TEST_F):

  • UIProcess/efl/PageUIClientEfl.cpp: Removed unnecessary calls to evas_object_focus_set().

(WebKit::PageUIClientEfl::takeFocus):

Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r171171 r171182  
     12014-07-17  Sanghyup Lee  <sh53.lee@samsung.com>
     2
     3        [EFL][WK2] Add a "focus,notfound" signal.
     4        https://bugs.webkit.org/show_bug.cgi?id=134674
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        Add a "focus,notfound" signal to handover focus control to application
     9        because there are no elements of webview to focus on the given direction.
     10
     11        Application can decide to move the focus to next widget of ewk_view or something else
     12        by using this signal.
     13
     14        * UIProcess/API/efl/EwkViewCallbacks.h:
     15        * UIProcess/API/efl/ewk_view.h:
     16        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp: Added keyDown and keyUp function.
     17        (EWK2UnitTest::EWK2UnitTestBase::waitUntilDirectionChanged):
     18        (EWK2UnitTest::EWK2UnitTestBase::keyDown):
     19        (EWK2UnitTest::EWK2UnitTestBase::keyUp):
     20        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
     21        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
     22        (EWK2ViewTest::FocusNotFoundCallback):
     23        (TEST_F):
     24        * UIProcess/efl/PageUIClientEfl.cpp: Removed unnecessary calls to evas_object_focus_set().
     25        (WebKit::PageUIClientEfl::takeFocus):
     26
    1272014-07-16  Brady Eidson  <beidson@apple.com>
    228
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h

    r168961 r171182  
    2828
    2929#include "WKEinaSharedString.h"
     30#include "WKPageUIClient.h"
    3031#include "ewk_view.h"
    3132#include <Evas.h>
     
    5354    DownloadJobRequested,
    5455    FileChooserRequest,
     56    FocusNotFound,
    5557    NewFormSubmissionRequest,
    5658    LoadError,
     
    145147};
    146148
     149template <CallbackType callbackType>
     150struct CallBack <callbackType, Ewk_Focus_Direction> : public EvasObjectHolder {
     151    explicit CallBack(Evas_Object* view)
     152        : EvasObjectHolder(view)
     153    { }
     154
     155    void call(Ewk_Focus_Direction direction)
     156    {
     157        evas_object_smart_callback_call(m_object, CallBackInfo<callbackType>::name(), &direction);
     158    }
     159
     160    void call(const WKFocusDirection arg)
     161    {
     162        Ewk_Focus_Direction direction = (arg == kWKFocusDirectionForward) ? EWK_FOCUS_DIRECTION_FORWARD : EWK_FOCUS_DIRECTION_BACKWARD;
     163        call(direction);
     164    }
     165};
     166
    147167#define DECLARE_EWK_VIEW_CALLBACK(callbackType, string, type) \
    148168template <>                                                   \
     
    162182DECLARE_EWK_VIEW_CALLBACK(DownloadJobRequested, "download,request", Ewk_Download_Job*);
    163183DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request*);
     184DECLARE_EWK_VIEW_CALLBACK(FocusNotFound, "focus,notfound", Ewk_Focus_Direction);
    164185DECLARE_EWK_VIEW_CALLBACK(NewFormSubmissionRequest, "form,submission,request", Ewk_Form_Submission_Request*);
    165186DECLARE_EWK_VIEW_CALLBACK(LoadError, "load,error", Ewk_Error*);
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h

    r169997 r171182  
    4040 *   a file (or several) on the file system. Call ewk_file_chooser_request_ref() on the request object to process it
    4141 *   asynchronously.
     42 * - "focus,notfound", Ewk_Focus_Direction*: reports that there was no element to be focused on the given direction.
     43 *   The user can handle next focus behavior using the signal.
    4244 * - "form,submission,request", Ewk_Form_Submission_Request*: Reports that a form request is about to be submitted.
    4345 *   The Ewk_Form_Submission_Request passed contains information about the text fields of the form. This
     
    277279
    278280/**
     281 * Enum values used to set focus direction.
     282 */
     283typedef enum Ewk_Focus_Direction {
     284    EWK_FOCUS_DIRECTION_FORWARD = 0,
     285    EWK_FOCUS_DIRECTION_BACKWARD,
     286} Ewk_Focus_Direction;
     287
     288/**
    279289 * @typedef Ewk_View_Script_Execute_Cb Ewk_View_Script_Execute_Cb
    280290 * @brief Callback type for use with ewk_view_script_execute()
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp

    r169366 r171182  
    235235
    236236    while (!data.isDone() && !flag)
     237        ecore_main_loop_iterate();
     238
     239    return !data.didTimeOut();
     240}
     241
     242bool EWK2UnitTestBase::waitUntilDirectionChanged(Ewk_Focus_Direction &direction, double timeoutSeconds)
     243{
     244    CallbackDataTimer data(timeoutSeconds);
     245    Ewk_Focus_Direction initialDirection = direction;
     246
     247    while (!data.isDone() && direction == initialDirection)
    237248        ecore_main_loop_iterate();
    238249
     
    313324}
    314325
     326void EWK2UnitTestBase::keyDown(char* keyname, char* key, char* string, char* modifier)
     327{
     328    Evas* evas = evas_object_evas_get(m_webView);
     329    ASSERT(evas);
     330
     331    if (modifier) {
     332        evas_key_modifier_on(evas, modifier);
     333        evas_event_feed_key_down(evas, keyname, key, string, 0, 0, 0);
     334        evas_key_modifier_off(evas, modifier);
     335        return;
     336    }
     337
     338    evas_event_feed_key_down(evas, keyname, key, string, 0, 0, 0);
     339}
     340
     341void EWK2UnitTestBase::keyUp(char* keyname, char* key, char* string)
     342{
     343    evas_event_feed_key_up(evas_object_evas_get(m_webView), keyname, key, string, 0, 0, 0);
     344}
     345
    315346} // namespace EWK2UnitTest
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h

    r166355 r171182  
    5353    bool waitUntilURLChangedTo(const char* expectedURL, double timeoutSeconds = defaultTimeoutSeconds);
    5454    bool waitUntilTrue(bool &flag, double timeoutSeconds = defaultTimeoutSeconds);
     55    bool waitUntilDirectionChanged(Ewk_Focus_Direction &direction, double timeoutSeconds = defaultTimeoutSeconds);
    5556    Eina_List* waitUntilSpellingLanguagesLoaded(unsigned expectedLanguageCount, double timeoutValue = defaultTimeoutSeconds);
    5657
     
    6364    void multiUp(int id, int x, int y);
    6465    void multiMove(int id, int x, int y);
     66    void keyDown(char* keyname, char* key, char* string, char* modifier);
     67    void keyUp(char* keyname, char* key, char* string);
    6568
    6669private:
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

    r169997 r171182  
    238238
    239239        obtainedPageContents = true;
     240    }
     241
     242    static void FocusNotFoundCallback(void* userData, Evas_Object*, void* eventInfo)
     243    {
     244        Ewk_Focus_Direction* direction = static_cast<Ewk_Focus_Direction*>(eventInfo);
     245        Ewk_Focus_Direction* result = static_cast<Ewk_Focus_Direction*>(userData);
     246        *result = *direction;
    240247    }
    241248};
     
    12021209    EXPECT_EQ(3000, contentsHeight);
    12031210}
     1211
     1212TEST_F(EWK2ViewTest, ewk_focus_notfound)
     1213{
     1214    const char contents[] =
     1215        "<!DOCTYPE html>"
     1216        "<body><input type='text' autofocus></body>";
     1217    ewk_view_html_string_load(webView(), contents, 0, 0);
     1218    ASSERT_TRUE(waitUntilLoadFinished());
     1219
     1220    Ewk_Settings* settings = ewk_page_group_settings_get(ewk_view_page_group_get(webView()));
     1221    ewk_settings_spatial_navigation_enabled_set(settings, EINA_TRUE);
     1222
     1223    Ewk_Focus_Direction direction = EWK_FOCUS_DIRECTION_FORWARD;
     1224    evas_object_smart_callback_add(webView(), "focus,notfound", FocusNotFoundCallback, &direction);
     1225
     1226    keyDown("Tab", "Tab", 0, "Shift");
     1227    keyUp("Tab", "Tab", 0);
     1228
     1229    ASSERT_TRUE(waitUntilDirectionChanged(direction));
     1230    EXPECT_EQ(EWK_FOCUS_DIRECTION_BACKWARD, direction);
     1231
     1232    // Set focus to the input element again.
     1233    keyDown("Tab", "Tab", 0, 0);
     1234    keyUp("Tab", "Tab", 0);
     1235
     1236    keyDown("Tab", "Tab", 0, 0);
     1237    keyUp("Tab", "Tab", 0);
     1238
     1239    ASSERT_TRUE(waitUntilDirectionChanged(direction));
     1240    EXPECT_EQ(EWK_FOCUS_DIRECTION_FORWARD, direction);
     1241
     1242    evas_object_smart_callback_del(webView(), "focus,notfound", FocusNotFoundCallback);
     1243}
  • trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp

    r167653 r171182  
    9999}
    100100
    101 void PageUIClientEfl::takeFocus(WKPageRef, WKFocusDirection, const void* clientInfo)
    102 {
    103     // FIXME: this is only a partial implementation.
    104     evas_object_focus_set(toPageUIClientEfl(clientInfo)->m_view->evasObject(), false);
     101void PageUIClientEfl::takeFocus(WKPageRef, WKFocusDirection direction, const void* clientInfo)
     102{
     103    toPageUIClientEfl(clientInfo)->m_view->smartCallback<FocusNotFound>().call(direction);
    105104}
    106105
Note: See TracChangeset for help on using the changeset viewer.